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

What is the difference between virtual functions and pure virtual functions?

1 Answers  


When must you use a constructor initializer list?

0 Answers   Amazon,


What does it mean to take the address of a reference?

0 Answers   Amazon,


What Is A Conversion Constructor C++ ?

0 Answers   Amazon,


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

0 Answers  


What is a class in C++?

1 Answers   Amazon, TCS, UGC Corporation,


What is the difference between an ARRAY and a LIST in C++?

1 Answers   IBS, TCS,


Can we use THIS Pointer in static function – Reason in C++?

0 Answers  


Tell How To Check Whether A Linked List Is Circular ?

1 Answers   IBS, Infosys,


CDPATH shell variable is in(c-shell)

0 Answers   Siemens,


When would you choose to return an error code rather than throw an exception?

0 Answers   Amazon,


Find the Factorial of a number using a program.

0 Answers   Accenture,


Categories