Q:

C++ program to add two integer numbers

0

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.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Most popular and Searched C++ solved programs with Explanation and Output

Similar questions


need a help?


find thousands of online teachers now
C++ program to add two integer numbers using funct... >>