Search C Program | nimishsoft@gmail.com

Swap values of two Variables

/*    Swap the values of two Variables using three variables    */
#include<stdio.h>
int main()
{
 int a;
 int b;
 int c;

 printf("Type value of A : ");
 scanf("%i",&a);
 printf("\nType value of b : ");
 scanf("%i",&b);
 c=a;
 a=b;
 b=c;
 printf("A : %i",a);
 printf("\nb : %i",b);
 return 0;
}


Related Posts:
------------------------------------------------------------------------------
Swap values of two variables using XOR
http://cbasicprogram.blogspot.com/2012/01/swap-two-variables-using-xor.html

Swap two values without using third variable
http://cbasicprogram.blogspot.com/2012/01/swap-two-values-without-using-third.html

9 comments: