c++ Basic program: Adding two or more numbers.
This program will add two or more numbers. These numbers will be x and y.
#include<iostream.h>
#include<conio.h>
int main()
{
int x, y;
int sum;
cout<<"Enter first number to add = x=";
cin>>x;
cout<<"Enter second number to add = y=";
cin>>y;
sum=x+y;
cout<<"sum of two numbers is="<<sum;
getch();
return 0;
}
You can add as many numbers as you want in this way.
Output:
Enter first number to add = x= 5
Enter second number to add = y=98
sum of two numbers is=103