Write a program that will read integers and find the total and average of the input values. Your program should end when the input is 0.
#include <iostream>
using namespace std;
int main()
{
// let number of values is 5
int a,b,c,d,e, sum;
cout << "Enter the values:" << endl;
cin >>a>>b>>c>>d>>e;
// finding sum of the values
sum = (a+b+c+d+e) ;
cout << "Sum of numbers is: "<< sum << endl;
// average is sum/5
cout << "Average is :"<< (sum / 5) << endl ;
}
Comments
Leave a comment