0

How to write a pragrame that user gives N nuber and find average and largest no.

ans

16th May 2018, 4:36 PM
زوار اعجاز
زوار اعجاز - avatar
2 Answers
+ 1
#include <iostream> using namespace std; int main() { int n, i; float num[100], sum=0.0, average; cout << "Enter the numbers of data: "; cin >> n; while (n > 100 || n <= 0) { cout << "Error! number should in range of (1 to 100)." << endl; cout << "Enter the number again: "; cin >> n; } for(i = 0; i < n; ++i) { cout << i + 1 << ". Enter number: "; cin >> num[i]; sum += num[i]; } average = sum / n; cout << "Average = " << average; return 0; }
16th May 2018, 4:39 PM
Rajeeb
0
tnx bro
16th May 2018, 5:17 PM
زوار اعجاز
زوار اعجاز - avatar