Write a C++ Program to Find Sum and Average of three numbers.
Answer Posted / hr
Soluion:
/* C++ Program to Find Sum and Average of three numbers */
#include<iostream>
using namespace std;
int main()
{
float a,b,c,sum,avg;
cout<<"Enter 1st number :: ";
cin>>a;
cout<<"
Enter 2nd number :: ";
cin>>b;
cout<<"
Enter 3rd number :: ";
cin>>c;
sum=a+b+c;
avg=sum/3;
cout<<"
The SUM of 3 Numbers [ "<<a<<" + "<<b<<" + "<<c<<" ] = "<<sum<<"
";
cout<<"
The AVERAGE of 3 Numbers [ "<<a<<", "<<b<<", "<<c<<" ] = "<<avg<<"
";
return 0;
}
Output:
/* C++ Program to Find Sum and Average of three numbers */
Enter 1st number :: 3
Enter 2nd number :: 4
Enter 3rd number :: 5
The SUM of 3 Numbers [ 3 + 4 + 5 ] = 12
The AVERAGE of 3 Numbers [ 3, 4, 5 ] = 4
Process returned 0
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Which software is best for coding?
Write a function to perform the substraction of two numbers. Eg: char N1="123", N2="478", N3=-355(N1-N2).
Can we use pointers in c++?
What is the keyword auto for?
What is unary operator? List out the different operators involved in the unary operator.
Explain what is polymorphism in c++?
What are the various situations where a copy constructor is invoked?
What are libraries in c++?
What is the benefit of c++?
Can we declare a base-class destructor as virtual?
What is setf in c++?
What is an undefined reference/unresolved external symbol error and how do I fix it?
How would you use the functions sin(), pow(), sqrt()?
What is c++ in english?
What kind of problems can be solved by a namespace?