Technology has advanced to the point where programming has become an essential part of our lives. We use software and applications for communication, entertainment, education, and work, and these are all built on programming languages.

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.
Share:

No comments:

Post a Comment

If you have any doubt, let me know...

Translate

Wikipedia

Search results