fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int max(int x, int y) {
  5.  
  6. int result;
  7. if (x > y) {
  8. result = x;
  9. } else {
  10. result = y;
  11. }
  12.  
  13. return result;
  14. }
  15.  
  16. int main() {
  17.  
  18. int a = 10, b = 20;
  19. cout << "MAX = " << max(a, b) << endl;
  20.  
  21. int x = 30, y = 40;
  22. cout << "MAX = " << max(x, y) << endl;
  23.  
  24. return 0;
  25.  
  26. }
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
MAX = 20
MAX = 40