Skip to main content

Welcome to Coding 4 Programming

Addition of Two Binary Numbers | Function | Python

Addition of Two Numbers | C++

  

Program of Addition of Two Numbers in C++


#include<iostream.h> 
#include<conio.h> 
void main()
{
 clrscr();
 cout<<"\n\t Welcome to Coding 4 Programming";
 int a,b,c;
 a=50;
 b=70;
 c=a+b;
 cout<<"\n\n\t The Addition of "<<a<<" and "<<b<<" is "<<c;
 getch();
}


Compiler Screen:

Additin of C++
Compiler Screen

Output Screen:

Addition in C++
Output Screen




Notes:

1. In Header Files (line 1 and line 2) .h is not required in some compilers.

2. iostream.h (line 1) header file is used for output (cout) services.

3. conio.h (line 2) header file is used for clrscr() and getch() functions.

4. Instead of void main (line 3) some may use int main.

5. Some new compiler required using namespace std; before main function (line 3).

6. clrscr() (line 5) function is used for clear the previous output on output screen.

7. \n is used for new or next line.

8. \t is used for giving tap space.

9. In line 7, we declared three variable of integer data type named (identifier) as aand c. a and b for the number which user want to be add and c for storing the result (addition of a and b).

10. In line 8 and 9, we are assigning the value of a (line 8) and b (line 10) i.e., 50 and 70 respectively to a and b.

11. In line 10, we are giving formula (a+b) to the program for addition of a (a=50) and b (b=70) and assigning the result (a+b => 50+70=120) in variable c, you can also change the formula for the program of Subtraction and Multiplication.

14. cout (line 6 and 11) is used for the display anything (content) on output screen.

15. getch() (line 12) function is used for freezing the output screen.

16. Braces i.e., {} (line 4 and line 13) is used for the block. That means from line 4 to line 13 is single block.

Comments

Popular Posts