Ternary operator

Find the smallest among three numbers using conditional operator.

smallest = (num1 < num2) ? ((num1 < num3) ? num1 : num3) : ((num2 < num3) ? num2 : num3);

1 Like

smallest=(a<b&&a<c)?a:(b<c)?b:c

1 Like