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

Our Services

Search This Blog

  • ()
Powered by Blogger.

C Data Types and Types of data types in C

Data types specify the type of data that a variable can store. All C compilers support Five fundamental data types, they are an integer(int...

Blog Archive