Advertisement
afrinahoque

Swap two numbers using function.

Jul 6th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.27 KB | None | 0 0
  1. #include<stdio.h>
  2. void swapping(int *ptr1, int *ptr2)
  3. {
  4.     int temp;
  5.     temp = *ptr1;
  6.     *ptr1 = *ptr2;
  7.     *ptr2 = temp;
  8. }
  9. int main()
  10. {
  11.     int num1, num2;
  12.     scanf("%d %d", &num1, &num2);
  13.     swapping(&num1, &num2);
  14.     printf("%d %d", num1, num2);
  15.  
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement