/* 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
#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
thanks for such posts!
ReplyDeleteSwap the values of the two variables using and without using third variables (use function).
ReplyDeletesame program using function
ReplyDeletesuprbb
ReplyDeleteone line code.
ReplyDeletea^=b^=a^=b;
one line code ;)
ReplyDeleteb=a+b-(a=b);
Super brother..
DeleteNice article admin thanks for share your atricle keep share your knowledge i am waiting for your new post check mens winter jackets polo shirts kindly review and reply me
ReplyDeleteWhat is %i
ReplyDelete