Print sum and average of 5 numbers in C++
cout - Question 10
In this question, we will see how to print the sum and average of 5 numbers in C++ programming using the cout statement. To know more about cout statement click on the cout statement lesson.
Q10) Write a program in C++ to print the sum and average of 5 number like 9, 5, 8, 34, and 15.
Program
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
cout<<"Sum of of 9, 5, 8, 34, and 15 = "<<9+5+8+34+15<<endl;
cout<<"Average of 9, 5, 8, 34, and 15 = "<<(9+5+8+34+15)/5.0;
return 0;
}
Output
Sum of of 9, 5, 8, 34, and 15 = 71 Average of 9, 5, 8, 34, and 15 = 14.2