SabirSazzad

Swap function (Using pointer)

Feb 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. void swipe(int&x, int&y);
  4. int main ()
  5. {
  6.     int a=10,b=20;
  7.     swipe(a,b);
  8.     cout << a << "\n" << b;
  9.  
  10.     return 0;
  11. }
  12.  
  13. void swipe(int&x, int&y)
  14. {
  15.    int temp;
  16.    temp = x;
  17.    x = y;
  18.    y = temp;
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment