C++ Program to Add Two Numbers

Here you will get C++ program to add two numbers.

The program will ask user to enter two numbers and then calculate their sum.

#include<iostream>

using namespace std;

int main()
{
	int x,y,sum;
	
	cout<<"Enter first no: ";
	cin>>x;
	cout<<"Enter second no: ";
	cin>>y;
	
	sum=x+y;
	cout<<"\nSum = "<<sum;

	return 0;
}

Output

Enter first no: 4
Enter second no: 6

Sum = 10

6 thoughts on “C++ Program to Add Two Numbers”

  1. its very helpful to me

    i am a student studing in +2 computer science
    i am also interested in programing
    i am also from india

  2. using namespace std says if you find something that is not declared in the current scope go and check std. using namespace std; are used. It is because the computer needs to know the code for the cout, cin functionalities and it needs to know which namespace they are defined.

Leave a Comment

Your email address will not be published. Required fields are marked *