c++ Basic program: Adding two or more numbers.

Posted on at


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

 

 



About the author

noshaba-bibi

I am Noshaba Bibi ,24 years old ,
done Mcs from Virtual university and I am a blogger.

Subscribe 0
160