Program: Sum of Two Numbers in C
Sum of two variables in C programs:
#include<stdio.h>
int main()
{
int var1;
int var2;
int var3;
printf("Type the first value var1 = ");
int main()
{
int var1;
int var2;
int var3;
printf("Type the first value var1 = ");
scanf("%d",&var1);
printf("Type the second value var2 = ");
printf("Type the second value var2 = ");
scanf("%d",&var2);
var3 =var2+var1;
printf("var3 = %d",var3);
return 0;
}
var3 =var2+var1;
printf("var3 = %d",var3);
return 0;
}
Output:
Type the first value var1 = 7
Type the second value var2 = 3
var3 = 10
Type the second value var2 = 3
var3 = 10
Explanation:
- First three integers variables var1, var2, var3 are declared.
- The values of var1, var2 are entered from the keyword by the user.
- The addition of two variables values var1, var2 are stored in var3.
- In the last printf prints the value of var3.
See also: