Write a program which repeatedly reads numbers until the user enters 0. Once 0 is entered, print out the total, count, and average of the numbers. Use an array to store all the numbers. Example of execution:
Enter a number: 4
Enter a number: 5
Enter a number: 9
Enter a number: 0
Total = 18, count = 3, average= 6
answer by using while,for and array if possible
1
Expert's answer
2017-12-07T07:13:06-0500
#include <iostream>
using namespace std;
int main() { cout << "Input numbers.\n"; cout << "To finish entering input 0.\n"; int countEl = 0; double sum = 0; int element; cin >> element; while (element){ sum += element; countEl++; cin >> element; };
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment