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 total = 0;
unsigned int counter = 0;
while(counter < 3)
{
total += areas[counter];
++counter;
}
int average = total / 3;
cout << "Average is " << average << endl;
}
Comments
Leave a comment