/* swap.c */ /* function swap to swap two numbers */ #include <stdio.h> void swap(int*, int*); void swapBit(int*, int*); int main(){ int x, y; printf("Please enter two numbers: "); scanf("%d %d", &x, &y); printf("Before: "); printf("x, y = %d, %d ", x, y); swap(&x, &y); printf("After swap(): "); printf("x, y = %d, %d ", x, y); swapBit(&x, &y); printf("After swapBit(): "); printf("x, y = %d, %d ", x, y); return 0; } void swap(int* x, int* y){ int tmp = *x; *x = *y; *y = tmp; } void swapBit(int* x, int* y){ *x ^= *y; *y ^= *x; *x ^= *y; }