/************************/ /* swap.c */ /* Weiwei Chen 07/27/12 */ /************************/ #include int main(void) { int x1, y1, t; int x2, y2; x1 = 27; y1 = 42; printf("Before swapping: x1 = %d, y1 = %d \n", x1, y1); t = x1; x1 = y1; y1 = t; printf("After swapping: x1 = %d, y1 = %d \n", x1, y1); x2 = 18; y2 = 32; printf("Before swapping: x2 = %d, y2 = %d \n", x2, y2); x2 = x2 + y2; y2 = x2 - y2; x2 = x2 - y2; printf("After swapping: x2 = %d, y2 = %d \n", x2, y2); return 0; }