C++ Program to Add Two Numbers

We can add two numbers in C++ program. + operator is used to add two or more numbers. We can also subtract, Multiply, Divide two numbers in C++ language. It is very easy to add multiple numbers in C++ Language. You can also add two numbers in C language.

C++ Program to Add Two Numbers

C++ Program to Add Two Numbers

Source Code of Addition of Two Numbers in C++

#include <iostream>
using namespace std;

int main()
    int firstNumber, secondNumber, sumOfTwoNumbers;
    cout << "Enter two integers: ";
    cin >> firstNumber >> secondNumber;

    // sum of two numbers in stored in variable sumOfTwoNumbers
    sumOfTwoNumbers = firstNumber + secondNumber;

    // Prints sum 
    cout << firstNumber << " + " <<  secondNumber << " = " << sumOfTwoNumbers;     

    return 0;

Two variables are initialized in the starting of the program to store two integers such as firstnumber and secondnumber. When you enter the two integers + operator performs the addition of the two integers and store the value in another variable. The output value displays finally on the screen.

Read Also :-

1. Subtract Two Numbers in C++
2. Multiply Two Numbers in C++
3. Divide Two Numbers in C++


The output screen asks you to enter two integers. When you enter two integers it displays the two input integers. After the calculation the addition of two numbers displays on the output screen.

Enter two integers: 4
4 + 5 = 9

Final Words

I hope this article helps you to Add Two Numbers in C++ Program. If you face any issues please let me know via the comment section. Share this article with other C++ program developers via social networks.

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment