Introduction

Control Statement

- Check Whether the Number is Even or Odd in C++
- Program to check whether the number is prime or not
- Program to check vowel or constant
- Program to check the largest number among three numbers
- Program to the sum of natural numbers
- Program to check leap year
- Program to find factorial of the number
- Program to find reverse of the number
- Program to Check Armstrong Number

Function

- Program to find LCM
- Program to check prime number using Functions
- Program to convert Binary to Decimal Number
- Program to convert Decimal to Binary Number
- Program to convert Binary to Octal Number
- Program to convert Octal to Binary Number
- Program to find reverse of the sentence using Recursion
- Program to Shutdown and restart Computer
- Program to find the area of triangle

Array

Pointer

OOPS

No Examples found for this topic - CodeHelpPro

# Program to add two number

In this example, We will learn how to add two number entered by user.

This program will ask two number. After user provide two numbers, then program will print the sum of that two number.

```
#include <iostream>
using namespace std;
int main()
{
int num1, num2, sum;
cout << "Enter two integers: ";
cin >> num1 >> num2;
// sum of two numbers in stored in variable sum
sum = num1 + num2;
// Prints sum
cout << num1 << " + " << num2 << " = " << sum;
return 0;
}
```

The output of above program is

```
Enter two integers: 10 22
10 + 22 = 32
```

We have declared three variables on this program. Two variables (*num* and *num1*) are used to store the number given by the user and then after we will add these numbers and store them in the *sum* variable. Finally, We will print that sum using cout object.

Subscribe

Login

0 Comments

Inline Feedbacks

View all comments