C Programs
Friday, October 4, 2013
Write a C program code to swap using bitwise XOR
#include <stdio.h>
int main()
{
int x, y;
scanf("%d%d", &x, &y);
printf("x = %d\ny = %d\n", x, y);
x = x ^ y;
y = x ^ y;
x = x ^ y;
printf("x = %d\ny = %d\n", x, y);
return 0;
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment