Home »
C++ programs »
C++ Most popular & searched programs
C++ program to add two integer numbers
Given two integer numbers, we have to add them using C++ program.
[Last updated : February 28, 2023]
Adding two integer numbers
This is a very basic C++ program; here we are reading two integer numbers through the use and calculating sum of the number.
Firstly, we are declaring two integer numbers num1 and num2, then we will take input from the user using cin. Then we will calculate sum and store into variable add, and then display the value of add.
Program to add two numbers in C++
#include <iostream>
using namespace std;
int main()
{
int num1; //to store first number
int num2; //to store second number
int add; //to store addition
//read numbers
cout << "Enter first number: ";
cin >> num1;
cout << "Enter second number: ";
cin >> num2;
//calculate addition
add = num1 + num2;
//print addition
cout << "Addition is: " << add << endl;
return 0;
}
Output
Enter first number: 100
Enter second number: 200
Addition is: 300