tampurus

0.1 Swap two number using function

Dec 8th, 2021 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. #include<stdio.h>
  2. void Swap(int *p_a , int *p_b){
  3.     int a = *p_a;
  4.     *p_a = *p_b;
  5.     *p_b = a;
  6. }
  7. int main()
  8. {
  9.     int a=5,b=6;
  10.     printf("before a = %d b = %d\n",a,b);
  11.     Swap(&a,&b);
  12.     printf("after a = %d b = %d",a,b);
  13.     return 0;
  14. }
  15. /*
  16. Ouput
  17. before a 5 b 6
  18. before a 6 b 5
  19. */
Add Comment
Please, Sign In to add comment