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
Thanks.. We can also add two numbers using pointers in C.
I m not understand
it is not working
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
Can anyone explain the use of “using namespace std”, please?
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.