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
Post A Comment:
0 comments: