Advertisement
MeehoweCK

Untitled

Jul 2nd, 2021
1,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void funkcja(int& liczba)       // funkcja pobiera zmienną przez tzw. referencję - będzie ona pracowała na oryginalnej zmiennej
  6. {
  7.     cout << liczba << endl;     // 2. 10
  8.     ++liczba;
  9.     cout << liczba << endl;     // 3. 11
  10.     liczba *= 3;
  11.     cout << liczba << endl;     // 4. 33
  12.     --liczba;
  13.     cout << liczba << endl;     // 5. 32
  14. }
  15.  
  16. int main()
  17. {
  18.     int liczba = 10;
  19.     cout << liczba << endl;     // 1.   10
  20.     funkcja(liczba);
  21.     cout << liczba << endl;     // 6.   32
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement