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


Please Help Members By Posting Answers For Below Questions

What are the different types of polymorphism in c++?

589


What are the vectors in c++?

581


Who created stl?

652


How do you decide which integer type to use?

577


What does namespace mean in c++?

555






What is std :: endl?

596


Explain the differences between list x; & list x();.

602


What is called array?

621


Explain about Garbage Collector?

649


How to declaring variables in c++?

661


What do you mean by early binding?

600


What is private, public and protected inheritance?

592


Who calls main function?

586


Why is c++ considered difficult?

644


Is arr and &arr are same expression for an array?

582