How to Swap Two Numbers Without Using Temporary or Third Variable

This video tutorial explains how you can swap two numbers without using third or temporary variable in any programming language.
Here in this tutorial i have explained this program using c programming language and logic is the same for any other programming language.

Source code for this video tutorial

#include <stdio.h>
#include <stdlib.h>

int main()
   int a ,b;
   printf("Enter the two values to swap\n");
   printf("before swapping a = %d and b = %d\n",a,b);

   a = a+b;
   b = a-b;
   a = a-b;

    printf("after swapping a = %d and b = %d",a,b);
    return 0;

Back To Top