Robert_JR

Number Swap Using Pointer

Aug 30th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <string.h>
  4.  
  5. void swapp(char *p, char *q)
  6. {
  7.     int swa;
  8.     swa = *p;
  9.     *p = *q;
  10.     *q = swa;
  11. }
  12.  
  13.  
  14. int main()
  15. {
  16.     char ch1[10];
  17.     char ch2[10];
  18.  
  19.     int num1 , num2;
  20.  
  21.     scanf("%d %d", &num1, &num2);
  22.     //printf("%d %d\n", num1, num2);
  23.  
  24.     swapp(&num1, &num2);
  25.  
  26.     printf("%d %d\n", num1, num2);
  27.  
  28.     return 0;
  29. }
Add Comment
Please, Sign In to add comment