Write a C++ Program to Find Sum and Average of three numbers.



Write a C++ Program to Find Sum and Average of three numbers...

Answer / 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

More C++ Interview Questions

Explain the difference between C and C++.

0 Answers   Accenture,


Write a program that can take input from 3 to 8 and calculate the average?

0 Answers   Accenture,


How to convert integer to string in C++

0 Answers  


Question on Copy constructor.

0 Answers   Alter,


What is an abstract class?

5 Answers   Siemens,






What Is A Default Constructor in C++ ?

0 Answers   Amazon,


In C++ what do you mean by Inheritance?

0 Answers   Accenture,


What are the advantages and disadvantages of B-star trees over Binary trees?

0 Answers  


What is data abstraction? How is it implemented in C++?

0 Answers   Amdocs,


How will you execute a stack using a priority queue? (Push and pop should be in O (1)).

0 Answers   Adobe,


What are the different scope C++ provide ?

0 Answers   Amdocs,


Write a program that ask for user input from 5 to 9 then calculate the average

0 Answers   IBS,


Categories