Programming Challenges

Solve programming challenges related to expressions.

Challenge 1: Calculating max in functional style

The following imperative code calculates the maximum of three given variables by repeatedly updating max_number:

int x = 10;
int y = 2;
int z = 5;

int max_number = x;
if (max_number < y) {
   max_number = y;
}
if (max_number < z) {
   max_number = z;
}

Write the following code in a functional style in OCaml.

Get hands-on with 1200+ tech skills courses.