Make a c++ program that will print the average of the values of an array named areas with values 84, 76, 48 using while loop.
#include <iostream>
using namespace std;
int main()
{
int areas[3] = {84, 76, 48};
int sum = 0;
int n = 0;
while(n < 3)
{
sum += areas[n];
++n;
}
int average = sum / 3;
cout << "Average is " << average << endl;
}
Comments
Leave a comment