Maximum of four integer numbers P73231


Statement
 

pdf   zip   main.cc   main.c   main.java   main.py

thehtml

Write a function that returns the maximum of four given integer numbers a, b, c and d.

Interface

C++,C
int max4(int a, int b, int c, int d);
Java
public static int max4(int a, int b, int c, int d);
Python
max4(a, b, c, d) # returns int
 
max4(a: int, b: int, c: int, d: int) -> int

Observation You only need to submit the required procedure; your main program will be ignored.

Hint

Using function max2(a, b) of exercise ‍ could be useful.

Public test cases
  • Input/Output

    max4(10, 20, 5, 8) → 20
    max4(0, -2, 15, 15) → 15
    max4(-1, -2, -3, -4) → -1
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C C++ Java Python
    User solutions
    C C++ Java Python