#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.
#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.
If you have any doubt, let me know...