Header Ads

WAP to Add 2 Variables without using 3rd Variable in C - 41

This Program does Addition 2 Variables without using 3rd Variable in C.

Program Code:

/* Program to Add 2 Variables without using 3rd Variable */

#include <stdio.h>
int main() 
{
 int n1, n2;

        /* get the input from the user */
        printf("\n Enter First Number : ");
        scanf("%d", &n1);
        printf(" Enter Second Number : ");
        scanf("%d", &n2);

        /* add the given numbers */
        n1 = n1 + n2;
        printf(" Sum of '%d' and '%d' is %d\n", n1-n2, n2, n1);
 printf("\n CodeGig.org\n\n");        
 return 0;
  }

Program Ouput:

No comments