Answer to Question #340169 in C++ for Chubby

Question #340169

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.


1
Expert's answer
2022-05-13T17:02:19-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS