Addition of two numbers program in C++

In this basic C++ program series, we will have a look at how to add two numbers in the C++ programming language. In this C++ program, the user is required to enter two integers. The sum of these two integers will then be stored in a variable and displayed on the screen.

Addition of two numbers program in C++

#include <iostream>
using namespace std;
int main()
    int x, y, sum;
    cout << "Enter two integers: ";
    cin >> x >> y;
    // sum of two numbers in stored in variable sum
    sum= x + y;
    // Prints sum 
    cout << x << " + " << y << " = " << sum;     
    return 0;


Enter two integers: 10
10 + 20 = 30

Leave a Comment

Your email address will not be published. Required fields are marked *