1
0

swap1.c 436 B

1234567891011121314151617181920212223
  1. /* swap1.c -- first attempt at a swapping function */
  2. #include <stdio.h>
  3. void interchange(int u, int v); /* declare function */
  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) /* define function */
  13. {
  14. int temp;
  15. temp = u;
  16. u = v;
  17. v = temp;
  18. }