/* Swap values of two variables using XOR */
#include<stdio.h>
int main()
{
int a;
int b;
printf("Type value of A : ");
scanf("%i",&a);
printf("\nType value of b : ");
scanf("%i",&b);
a ^= b;
b ^= a;
a ^= b;
printf("A : %i",a);
printf("\nB : %i",b);
return 0;
}
Related Posts:
------------------------------------------------------------------------------
Swap two values without using third variable
http://cbasicprogram.blogspot.com/2012/01/swap-two-values-without-using-third.html
Swap values of two variables
http://cbasicprogram.blogspot.com/2012/01/swap-values-of-two-variables-c-program.html
#include<stdio.h>
int main()
{
int a;
int b;
printf("Type value of A : ");
scanf("%i",&a);
printf("\nType value of b : ");
scanf("%i",&b);
a ^= b;
b ^= a;
a ^= b;
printf("A : %i",a);
printf("\nB : %i",b);
return 0;
}
Related Posts:
------------------------------------------------------------------------------
Swap two values without using third variable
http://cbasicprogram.blogspot.com/2012/01/swap-two-values-without-using-third.html
Swap values of two variables
http://cbasicprogram.blogspot.com/2012/01/swap-values-of-two-variables-c-program.html
can u show the output please
ReplyDeleteNice artical, keep it up Patterns in C
ReplyDeletemonsnuZtastnuIndependence Jennifer Williams https://wakelet.com/wake/u0Dtzt0O7Mp2Aech2k5Dg
ReplyDeletelinkaeconsdis
scanacWpeiaDes Moines Sarah Metcalf click
ReplyDeletethere
genmocorpo