Fan: Dasturlash 1 Talaba: Berdimurodov Fozilbek Guruh: 063-21 Mustaqil ish


Download 71.05 Kb.
Sana02.08.2023
Hajmi71.05 Kb.
#1664580
Bog'liq
Berdimurodov mustaqil ish


Fan: Dasturlash 1
Talaba: Berdimurodov Fozilbek
Guruh: 063-21

Mustaqil ish



#include
#include
using namespace std;
int main() {
int n;
cout << "Massiv uzunligini kiriting: ";
cin >> n;

if (n <= 0) {


cout << "Massiv uzunligi musbat bo'lishi kerak!" << endl;
return 1;
}

vector arr(n);


for (int i = 0; i < n; ++i) {


cout << "Element #" << (i + 1) << ": ";
cin >> arr[i];
}

double sum = 0;


for (double num : arr) {
sum += num;
}

double average = sum / n;


cout << "Massivdagi elementlar o'rta arifmetikasi: " << average <<
endl;

return 0;


}

Download 71.05 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling