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
Is c++ an oop?
Is java made in c++?
Why do we use double in c++?
How to get the current position of the file pointer?
When do we run a shell in the unix system? How will you tell which shell you are running?
What is the use of data hiding?
Function can be overloaded based on the parameter which is a value or a reference. Explain if the statement is true.
What is the standard template library (stl)?
What does no cap mean?
Why the usage of pointers in C++ is not recommended ?
Can a program run without main in c++?
Discuss the possibilities related to the termination of a program before entering the mainq method?
What is the full form of c++?
Does c++ vector allocate memory?
Do we have to use initialization list in spite of the assignment in constructors?