It should be in C Write a program in C that calculates avera
It should be in C++
Write a program in C++ that calculates average of numbers stored in an array. There should be array declaration in main() to store the flowing number average[]: {6, 72, 32, 45, 86 94, 9. 98, 8, 10}.Solution
// Program to calculate average of numbers in array average[]
#include <iostream>
using namespace std;
int main()
{
int average[10]={6,72,32,45,86,94,9,98,8,10}; //array declaration and initialization
int i,sum=0;
float avg;
for(i=0;i<10;i++)
sum+=average[i]; // calculate sum of all the elements in array
avg=sum/10; // calculate average by dividing total element in array i.e. 10
cout << \"Average = \" <<avg<<endl;
return 0;
}
/* Output
Average = 46
*/
