a) Write a C++ program that accepts 5 integers from a user and then display the accurate average?
Answers
Answered by
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
History,
9 days ago
Math,
18 days ago
Math,
18 days ago
Political Science,
9 months ago
Math,
9 months ago