What does the following function do?

can someone tell me how does this function work? what is the use of ? and :

int get_smallest(int num1, int num2) {
  
  return num2 < num1? num2 : num1;
  
}

It’s a ternary operator.

It reads like this is num2 less than num1? then return num2, otherwise return num1.

Here’s documentation for a more specific description:

2 Likes

Thank you so much :slight_smile: