1
0

swap2.c 472 B

12345678910111213141516171819202122232425
  1. /* swap2.c -- researching swap1.c */
  2. #include <stdio.h>
  3. void interchange(int u, int v);
  4. int main(void)
  5. {
  6. int x = 5, y = 10;
  7. printf("Originally x = %d and y = %d.\n", x , y);
  8. interchange(x, y);
  9. printf("Now x = %d and y = %d.\n", x, y);
  10. return 0;
  11. }
  12. void interchange(int u, int v)
  13. {
  14. int temp;
  15. printf("Originally u = %d and v = %d.\n", u , v);
  16. temp = u;
  17. u = v;
  18. v = temp;
  19. printf("Now u = %d and v = %d.\n", u, v);
  20. }