Add two numbers

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,sum=0;
clrscr();
printf(” Enter the value of the First number = “);
scanf(“%d”,&a);
printf(” Enter the value of the Second number = “);
scanf(“%d”,&b);
sum=a+b;
printf(” Sum = %d”,sum);
getch();
}

Explanation of Program :
1. We take one variable with name a
.
2 We take second variable with name b .
3 Print Message for user so that he/she can enter two Integer number .
4 Take user’s first input and convert into Int and assign to a .
5 Take user’s second input and convert into Int and assign to b .
6 Add a and b values and assigned to variable sum .
7 Print result to user on Output Screen .

Output :

Posted in: C

Leave a Reply

Your email address will not be published. Required fields are marked *