C++ Program to Add Two Numbers

In this example, we take two numbers from the user and add those two numbers and display the sum. The below example takes two number and stores it in the variable “a” and “b” respectively. Another variable “sum” is declared that is used to store the addition of two numbers entered by the user.


using namespace std;
int main()
	int a, b, sum;
	cout<<"Enter two number: ";
	cout<<"Sum of the two number is: "<<sum;
	return 0;

The output of the above program is:


Enter two number: 5
Sum of two number is: 10

In the output section of this program, at first, it displays “Enter two number”. After the user entered the numbers, the compiler displays the sum of these two numbers as shown above.

SHARE C++ Program to Add Two Numbers

You may also like...

Leave a Reply

Your email address will not be published.