Computer Science, asked by shawalsheikh163, 18 days ago

a) Write a C++ program that accepts 5 integers from a user and then display the accurate average?

Answers

Answered by samarthkrv
0

Answer:

#include <iostream>

using namespace std;

int main()

{

double avg;

int total;

int arr[5];

cout << "Enter all 5 numbers-";

   for(int i = 0; i < 5; i++){

       int x;

       cin >> x;

       arr[i] = x;

   }

   for(int i = 0; i < 5; i++){

        total = total + arr[i];

   }

   avg = total / 5.0;

   cout << "The average of the 5 numbers is " << avg <<endl;

}

Explanation:

Similar questions