Advertisement
Guest User

ampersand

a guest
Oct 14th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void square(int& a)
  5. {
  6. a = a * a;
  7. return;
  8. }
  9.  
  10. //THIS IS AN EXAMPLE OF FAILURE.
  11. /*
  12. int main()
  13. {
  14. int x = 1;
  15. int y = 2;
  16. square(x + y);
  17. cout << x;
  18. return 0;
  19. }
  20. */
  21.  
  22. int main()
  23. {
  24. int x = 1;
  25. int y = 2;
  26. int z = x + y;
  27. square(z);
  28. cout << x;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement