Dremendo Tag Line

Input 2 numbers and find their sum in C++

cin - Question 1

In this question, we will see how to input two numbers in C++ programming using the cin statement and find their sum. To know more about cin statement click on the cin statement lesson.

Q1) Write a program in C++ to input two numbers and find their sum.

Program

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    int a,b,c;
    cout<<"Enter 2 numbers\n";
    cin>>a>>b;
    c=a+b;
    cout<<"Sum="<<c;
    return 0;
}

Output

Enter 2 numbers
15
26
Sum=41
video-poster