In this article you will be learning about c + program to accept two numbers and find their sum. This program is used to demonstrate the arithmetic addition operation in c plus plus.


Question : write a c + program to accept two numbers and find their sum

In the below program we include the library io stream and start the main by defining two numbers number1 and number2 and an integer sum.

We accept the two numbers form the user and calculate the sum of number1 and number2. After calculating the sum we print the sum using console out.

Program:

#include <iostream>
using namespace std;

int main()
{
    int number1, number2, sum;
    cout << "Enter first number : ";
    cin >> number1;
    cout << "Enter second number : ";
    cin >> number2;

    sum = number1 + number2;
    cout << "Sum of " << number1 << " + " <<  number2 << " = " << sum;     
    return 0;
}


OUTPUT1 :

Enter first number : 25
Enter second number : 42
Sum of 25 + 42 = 67

OUTPUT2 :

Enter first number : 273  
Enter second number : 2323
Sum of 25 + 42 = 2596 


This is the C + program to accept two numbers and find their sum