Advertisement
levartolona

C_PRG_LANG_EX_4.14

Feb 1st, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define SWAP(type, x, y){\
  4. type tmp = x;\
  5. x = y;\
  6. y = tmp;\
  7. }
  8.  
  9. int main(void)
  10. {
  11.     int x = 5;
  12.     int y = 8;
  13.     printf("x = %d, y = %d\n", x, y);
  14.     printf("SWAP\n");
  15.     SWAP(int, x, y);
  16.     printf("x = %d, y = %d\n", x, y);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement