C++ Program to Add Two Numbers

0
12

C++ Program to Add Two Numbers
In this program, the user is asked to enter two integers. Then, the sum of those two integers is stored in a variable and displayed on the screen. Primary tabs.

Program:

#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;
}

OutPut :

Enter two integers: 2
5
2 + 5 = 7

LEAVE A REPLY

Please enter your comment!
Please enter your name here