Home » C++ programs » C++ Most popular & searched programs

C++ program to add 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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.