193030

Parameters passing - Call by adress

Aug 9th, 2020 (edited)
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. void swap(int *x, int *y)
  5. {
  6.     int temp = *x;
  7.     *x = *y;
  8.     *y = temp;
  9. }
  10. int main()
  11. {
  12.     int a = 10;
  13.     int b = 30;
  14.     swap(&a, &b);
  15.     cout << a << " " << b << endl;
  16. }
  17.  
Add Comment
Please, Sign In to add comment