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
What is the use of "new" operator?
What is a null object in c++?
Can enum be null?
What are inline functions? What is the syntax for defining an inline function?
Does c++ cost money?
How to allocate memory dynamically for a reference?
What is the difference between the indirection operator and the address of oper-ator?
What are the various access specifiers in c++?
What do you mean by translation unit?
What is abstraction in oops with example?
How do c++ struct differs from the c++ class?
What causes a runtime error c++?
What is increment operator in c++?
Can class objects be passed as function arguments?
Where must the declaration of a friend function appear?