Program 2- Program to add two numbers

#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a=5;
int b=7;
int c;
c=a+b;
printf("Addition=%d", c);
getch();
}




Output
Addition=12



Explanation
int denotes that variable a can store only integer number so number 5 is provided to it. Varriable c is declared as integer and addition of the number a and b is now placed to c for mathematical calculation. Now to print the result, we have given %d as specifier of interger that holds the value of c.


Exercise:
Make a program that add 3 numbers.

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.