C Program to Swapping Two Numbers
The two numbers can be swap with the third variable, without third variable or be using bitwise XOR etc. To understand this example you should know Data Types In C Programming and Operators In C Programming Part: 1 before proceeding further. Using swap program we can exchange values of two values. Consider your program takes two values as a=5 and b=9 values after swap has become a=9 and b=5. Let see all methods one by one. 1. Swapping Using Third Variable #include<stdio.h> int main() { int a,b,temp; printf("Enter valude of a and b\n"); scanf("%d %d",&a,&b); printf("a and b before swap are a=%d and b=%d\n",a,b); temp=a; a=b; b=temp; printf("a and b after swap are a=%d and b=%d\n",a,b); return 0; } The ou...