Answer:
#include<iostream>
#include<cmath>
using namespace std;
int main(){
float num;
float sum = 0.0;
for(int i=1;i<=5;i++){
cout<<"\nPlease enter the number: ";
cin>>num;
sum = sum + round(num);
}
float avg = sum/5;
cout<<"The sum is: "<<sum<<endl;
cout<<"The average is: "<<avg<<endl;
}
Explanation:
Create the main function and declare the variable 'num' and define the variable sum with zero.
Then, take a for loop and it runs for 5 times because of the condition i<=5.
print the message for the user on the screen, then the user enters the decimal value. After that, round the decimal number to the nearest integer.
we can use inbuilt function round(), which is defined in the cmath library and it takes the argument decimal.
For example:
round(5.89) it gives the integer 6.
Then, take the sum of all-rounded value and this process runs for 5 times. after that, take the average by dividing the sum by 5.
and then, print the sum and average value.