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
Why should we use null or zero in a program?
Write a program in c++ to print the numbers from n to n2 except 5 and its multiples
What is oops and its features?
Why Pointers are not used in C++?
What is singleton class in c++?
Difference between pointer to constant vs. Pointer constant
what are the iterator and generic algorithms.
How we can differentiate between a pre and post increment operators during overloading?
How can virtual functions in c++ be implemented?
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?
Explain the concept of friend function in c++?
What is a far pointer? where we use it?
Describe linkages and types of linkages?
Explain class invariant.
Why is c++ still best?