×

C++ Programs

C++ Most popular & Searched Programs

C++ Basic I/O Programs

C++ Constructor & Destructor Programs

C++ Manipulators Programs

C++ Inheritance Programs

C++ Operator Overloading Programs

C++ File Handling Programs

C++ Bit Manipulation Programs

C++ Classes & Object 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

Related Programs

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.