Swapping Numbers without 3rd Variable

This is a simple  Program for Swapping of Variable without 3rd Variable. This is a part of Mumbai University MCA Colleges Cpp. It is also usually asked in Interviews.




Swapping of Variable without 3rd Variable


#include <stdio.h>
#include <iostream.h>
int main()
{
int a=11;
int b=20;
b=(a+b);                 // a = 11      b=31
a=(b-a);                  // a = 20      b=31
b=(b-a);                 //  a = 20      b=11
printf("%d %d",a,b);
return 0;
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

No comments:

Post a Comment