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 is polymorphism explain its types?

904


Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

744


Are vectors passed by reference c++?

720


What is the fastest c++ compiler?

772


How can you say that a template is better than a base class?

783


What happens if a pointer is deleted twice?

1014


Do class declarations end with a semicolon? Do class method definitions?

853


What is the use of 'using' declaration in c++?

840


How is c++ different from java?

773


C is to C++ as 1 is to a) What the heck b) 2 c) 10

827


Can enum be null?

756


What are the benefits of interface?

793


Explain the uses oof nested class?

871


What are the benefits of operator overloading?

892


What is basic if statement syntax?

768