This is an example program that demonstrates how you can perform the addition of two user given numbers in C++.
In this program first we are taking two integer numbers from the user, and then displaying the result of addition into the console.
Program
#include <iostream> using namespace std; int main() { int num1, num2, sum; cout << "Enter 1st number : "; cin >> num1; cout << endl << "Enter 2nd number : "; cin >> num2; sum = num1 + num2; cout << endl << "Result = " << sum; return 0; }
Output
Enter 1st number : 10
Enter 2nd number : 40
Result = 50