Addition of Two Numbers

Addition of two Numbers in C

The Addition of two numbers in c with the help of arithmetic operator and print the sum of two numbers. for example we enter two number is 6,6 and the sum is equal to 12.

#include<stdio.h>
#include<conio.h>
  void main()
  {
   int a,b,sum;
    printf("enter two numbers\n");
     scanf("%d%d",&a,&b);
       sum=a+b;
         printf("sum of two numbers=%d",sum);
          getch();
      }

Output:-


similarly, we create subtraction,multiplication,division program.

Addition using without third variable 

#include<stdio.h>
#include<conio.h>
  void main()
{
int a,b;
 printf("enter the two numbers\n");
  scanf("%d%d",&a,&b);
   a=a+b;
    printf("sum of two numbers=%d",a);
     getch();
}

Don't Recommended this Because of the the original value of a is lost so we cannot use any where the  original value of 'a'.


Output:-

No comments:

Post a Comment