# Thread: Simple ternary operation baffling me

1. ## Simple ternary operation baffling me

Code:
```#include <stdio.h>
#include <stdlib.h>

inline int min(int x, int y) { return x = y ? x : y; }

int main(int argc, char** argv) {

int x = 1;

int y = 15;

printf("x=%d,y=%d\n", x, y);

printf("min(x,y)=%d\n", min(x, y));

return (0);

}```
While Googling for some stuff I chanced upon above code. My idea of Ternary operation is in slight doubt. In code below I don't see any comparison.

Code:
`{ return x <= y ? x : y; }`
I would've written something like this:

Code:
`{return x = (x<y) ? x:y;}`
Hope I explained myself correctly.

2. The comparison is x <= y. If you really saw x = y, then it is probably just a typographical error.

3. In C, in order to compare two values, you must use the "==" operator. The "=" operator is used for assigning values.

Then the second code has comparison, the literal translation would be : "is x less than or equal to y? if yes, return x, otherwise return y".

Hope that helps.

4. @laserlight @Tibo-88: Thanks for quick revert. It was not typo; I was flummoxed seeing expression "x<=y" in ternary operation. But thanks for clarifying.

5. Using the '<=' operator is confusing in this case IMO because the function name is min() and the result is the same regardless, because if 'x == y' it does not matter which one is returned.