Q4) Write a program that stores the
following values in five different variable 28, 32.37,24 and 33. The program
should calculate the sum of these variables and store the result in separate
variable named sum. Then program should divide sum variable by 5 to get the
average. Display average on screen.
#include <iostream>
using namespace std;
int main()
{
int a,b,c,d,e,sum;
double avg;
a=28;
b=32;
c=35;
d=24;
e=33;
{
sum=a+b+c+d+e;
}
{
avg=sum/5;
}
cout<<"Average of five numbers = "<<avg<<endl;
return 0;
}
No comments:
Post a Comment