Addition of 2 numbers in C++ Program

In this programming tutorial we will see the Addition of 2 numbers in C++ program. We will declare 3 variables, take input values of 2 variables from user and store and display the total of those variables via the third variable.

Addition of 2 numbers in C++ (using 3rd variable)
#include <iostream> 
using namespace std;
int main()
{
   int a, b, c;
   cout << "Enter two numbers to add\n";
   cin >> a >> b;
   c = a + b;
   cout <<endl<<"Sum of entered numbers = " << c << endl;
	return 0;
}
Output
Enter two numbers to add
5 11
Sum of entered numbers = 16

Leave a Reply

Your email address will not be published. Required fields are marked *