calculate average of 4 numbers.
#include <iostream>
using namespace std;
#include <iomanip>
int main()
{
float num1,num2,num3,num4,avg;
cout<<"Enter first number:";
cin>> num1;
cout<<"Enter second number :";
cin>> num2;
cout<<"Enter third number :";
cin>> num3;
cout<<"Enter fourth number:";
cin>> num4;
avg=num1+num2+num3+num4/4.0;
cout<<fixed<<setprecision(2)<<"The average of the four number is:"<<avg<<endl;
}
0 Comments
Post a Comment