I have a question regarding the simplest method to find the smallest variable given the variables: x, y, z. Assume that all three variables are positive and distinct. And then assign the smallest value to the variable: smallest, and store the largest to the variable: largest.
The way I wrote the code is, imo, quite complicated, eg:
i have to use six if/else-if statements to check for:
x < y < z
x < z < y
y < x < z
y < z < x
z < x < y
z < y < x
But, this is simply a comparison between three variables, what if there are 10 or 100 variables to compare? That would be way to complex. So, is there a simpler way to code this?
Below is the only way comes into mind.