Answer to Question #339663 in C++ for Chubby

Question #339663

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-12T08:18:53-0400
#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;
}

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