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 a, b, sum;
cout<<"Enter two number: ";
cout<<"Sum of the two number is: "<<sum;
The output of the above program is:
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.