Swap without using third variable - C Program

C program to read two numbers and exchange their values without using third variable.

Solution:

In this program, swap the values of variable without using third variable.

#include <stdio.h>
int main()
{
      int a,b;
      printf("\tEnter Two Numbers\n");
      printf("----------------------------\n");
      printf("Enter First Number  : ");
      scanf("%d", &a);
      printf("\nEnter Second Number : ");
      scanf("%d",&b);
      printf("----------------------------\n");
      printf("\nBefore Exchange a= %d b=%d\n",a,b);
      /*Without using third variable*/
      a=a+b;
      b=a-b;
      a=a-b;
      printf("\nAfter Exchange  a=%d b=%d",a,b);
      return 0;
}


Output:
                                                              
swap without third