C++ program to add two numbers

These are simple  programs to accept two integers and print its sum.
Tested on Turbo c++
All Programs are correct but have some modifications....





//start
#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
 int a,b,sum;
cout<<"Enter two integers :";
cin>>a>>b;
sum=a+b;
cout<<"The sum of  "<<a<<"  and "<<b<<"  is "<<sum;
getch();
}
//end




                                                   OR

//start
#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
int a,b;
cout<<"Enter two integers :";
cin>>a>>b;
sum=a+b;
cout<<"The sum of given integers is :"<<sum;
getch();
}
//end



                                                       OR

//start
#include<iostream.h>
#include<conio.h>
void main()
{
  clrscr();
float a,b,sum;                                         //float used to perform addition of decimals
cout<<Enter two numbers ";
cin>>a>>b;
sum=a+b;
cout<<"The sum of given numbers is :"<<sum;
getch();
}
//end





Press          Alt+F9   to compile program.
Then Press Ctrl+F9  to run program.

If you need help ,comment below.

please share this blog to your friends

Subscribe us for Future posts (My C Plus Plus)
Thank you

About Author:

Hey Cyber Astronauts, Welcome to the one of best blog The CyberSpace HUB. I'm Himanshu Singh, a Part-time-blogger from India. Here at The CyberSpace HUB I write about Starting and managing a blog,Latest technology and Making Money online.


Join Me: Twitter | Facebook | Google Plus


EmoticonEmoticon