a. Prompts the user to input five decimal numbers.
b. Prints the five decimal numbers.
c. Converts each decimal number to the nearest integer.
d. Adds the five integers.
e. Prints the sum and average of the five integers
////////////// Soltion //////////////////
#include <iostream>
using namespace std;
int main() {
//// a part
float a,b,c,d,e;
int sum=0;
cout<<"Enter th score of first number"<<endl;
cin>>a;
cout<<"Enter th score of second number"<<endl;
cin>>b;
cout<<"Enter th score of third number"<<endl;
cin>>c;
cout<<"Enter th score of forth number"<<endl;
cin>>d;
cout<<"Enter th score of fifth number"<<endl;
cin>>e;
// part b
cout<<"first number is "<<a<<endl;
cout<<"second number is "<<b<<endl;
cout<<"third number is "<<c<<endl;
cout<<"forth number is "<<d<<endl;
cout<<"fifth number is "<<e<<endl;
///////////// part c
a=int(a);
b=int(b);
c=int(c);
d=int(d);
e=int(e);
///// part d
sum=a+b+c+d+e;
//////// part e
cout<<"The sum is "<<sum<<endl;
cout<<"The average is "<<sum/5<<endl;
}
No comments:
Post a Comment