fork download
  1. #include <iostream>
  2.  
  3. int cube(int variable)
  4. {
  5. variable = variable * variable * variable;
  6. return variable;
  7. }
  8.  
  9. int square(int & variable)
  10. {
  11. variable = variable * variable;
  12. return variable;
  13. }
  14.  
  15. int main()
  16. {
  17. int myVar = 3;
  18. std::cout << "The value of variable myVar is: " << myVar << "\n";
  19. std::cout << "The value returned by function cube() is: " << cube(myVar) << "\n";
  20. std::cout << "And the value of variable myVar after that is: " << myVar << "\n";
  21. std::cout << "The value returned by function square() is: " << square(myVar) << "\n";
  22. std::cout << "And the value of variable myVar after that is: " << myVar << "\n";
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
The value of variable myVar is: 3
The value returned by function cube() is: 27
And the value of variable myVar after that is: 3
The value returned by function square() is: 9
And the value of variable myVar after that is: 9