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

In this program, I take x and y as two int variables to store the values of number to be added and sum is a variable which store the addition of x and y.

Program Code: 
#include<iostream>
using namespace std;
int main()
{
int x;

int y;
int sum;
cout<< " Enter first number for addition : ";
cin>>x;
cout<<endl;
cout<<" Enter second number for addition : ";
cin>>y;
cout<<endl;
sum =x + y;
cout<<" The Sum is first and second number is = : "<<sum;
return 0;
}

The program output is tested on www.jdoodle.com
Output:
Enter first number for addition : 4
Enter second number for addition : 3
The Sum is first and second number is = : 7


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: