12th Class NCERT Solution Download Click Here!

X




Sunday, 13 March 2016

Write a program which accept two numbers and print their sum.

#include<iostream>
using namespace std;

int main()
{
 int a,b,c;
 cout<< "\nEnter first number : ";
 cin>>a;
 cout<<"\nEnter second number : ";
 cin>>b;
 c=a+b;
 cout<<"\nThe Sum is : "<<c;
 
 
 return 0;
}



Output:

Enter first number : 81
Enter second number : 93
The Sum is : 174

Hint : cin command is used for getting value for a variable. This value most of the times is assigned by user. 

No comments:

Post a Comment