Write a C++ Program to Compute the Sum and Average of Two Numbers

Engg.... | 01:04 | | Best Blogger Tips
Sum of Two Numbers

  • Manipulators are the Operators that are used to Format the Data Display.
  • Example: endl
  • It is included in the <iomanip> Header File.
Statement of C++ Program: Enter Two Numbers and Calculate the Sum and Average of Two Numbers:


int main()
float n1, n2 ;
float Sum, Average ;

Cout<< " Enter the Value of Two Numbers" << "endl";        
Cin>> n1;
Cin>> n2;
Sum = n1+ n2;
Average = Sum / 2 ;

Cout<< " Sum= " << Sum << "\n" ;
Cout<< " Average= " << Average << "\n" ;
return(0);                                                               // It is also Written as  return 0;
}                                                 // End of main()

 Enter the Value of Two Numbers
 5  10
 Sum= 15
 Average= 7.5

Please Share it! :)
Do you like this Story?

Get Free Email Updates Daily!

Follow us!

1 comment:

  1. Thanks for the efforts on gathering useful content and sharing here. You can find more questions and answers related to C, C++ programming and all other programming languages Q&A in the below forum.

    C CPP programming and programming languages Q&A