Sum of Two Numbers in C | Sum of Two Variables in C

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 = ");
   scanf("%d",&var1);
  printf("Type the second value 
var2 = ");
   scanf("%d",&var2);
  var3 =var2+var1;
   printf("var3 =  %d",var3);
  return 0;
 }
Output:
Type the first value var1 = 7
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.
    Sum of Two variables in C
  • In the last printf prints the value of var3.
See also:
Share:

Ads

Search This Blog

  • ()
Powered by Blogger.

Strings in C With Syntax, C String Program with output

Strings in C :  Strings can be defined as the one-dimensional array of characters terminated by a null ('\0'). The difference betwee...

Blog Archive