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:

  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int first_number, second_number, sum;
  6. cout << "Enter two integers: ";
  7. // Two integers entered by user stored
  8. cin >> first_number >> second_number;
  9. // Sum of the two numbers stored in the variable sum
  10. sum = first_number + second_number;
  11. // Displaying the value of sum
  12. cout << first_number << "+" << second_number << "=" << sum;
  13. return 0;
  14. }

Output:

Enter two integers: 7
17
7 + 17 = 24