A Program to Add Two Integer Numbers
In this example, we are giving a c++ program to add two integer numbers which are given by the user.
Program to add two integer numbers:
#include <iostream>
using namespace std;
int main()
{
int first_number, second_number, sum;
cout << "Enter two integers: ";
// Two integers entered by user stored
cin >> first_number >> second_number;
// Sum of the two numbers stored in the variable sum
sum = first_number + second_number;
// Displaying the value of sum
cout << first_number << "+" << second_number << "=" << sum;
return 0;
}
Output:
Enter two integers: 7 17 7 + 17 = 24