Adding two numbers in C++ program
Description:
In this post you can learn how you can add two number easily by making a simple C++ program at Turbo C++ software. Turbo c++ make it easy for you to learn programming with in no time. Here you can learn how you can add two integers easily by putting the codded program given you below.
File Structure:
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b,sum;
cout<<"This is my first program"<<endl;
cout<<"Addition of two numbers"<<endl;
cout<<"First numer: ";
cin>>a;
cout<<"/nsecond number: ";
cin>>b;
sum=a+b;
cout<<"/nsum= "<<sum;
getch();
}
#include<conio.h>
void main()
{
int a,b,sum;
cout<<"This is my first program"<<endl;
cout<<"Addition of two numbers"<<endl;
cout<<"First numer: ";
cin>>a;
cout<<"/nsecond number: ";
cin>>b;
sum=a+b;
cout<<"/nsum= "<<sum;
getch();
}
Just make your program like this to add two number which are a, b and their sum= a+b
Explanation:
The whole program can be explained easily below in points.
- Void main() is the predefined function.
- Cout<< the comand to show the desired text or result on screen.
- Int represents the integers which are a and b in this program.
- /n command to make the program to go to next line.
- #Include<iostream> directives to show results.
Post a Comment