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

Implement a 2D bit-matrix representing monochrome pixels which will have only OFF/ON values and will take on an average only one bit of memory for each stored bit. How to perform various operations on it?

0 Answers   Adobe,


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

1 Answers  


what do you mean by exception handling in C++?

0 Answers   Alter,


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

0 Answers   Accenture,


What is Copy Constructor?

5 Answers   ABC, Siemens,






If class D is derived from a base class B

0 Answers  


Tell me about virtual function

1 Answers  


What are the fundamental features of an object-oriented language?

0 Answers   Accenture,


Explain why C++ is not purely Object Oriented Language

0 Answers   Aspire,


In C++ what is the meaning of data hiding?

0 Answers   Aricent,


What is the 4 difference between delete[] and delete?

0 Answers   Alter,


Define an Abstract class in C++?

0 Answers  


Categories