Code for finding maximum of three numbers in c using ternary operator:
What is the output of below C program? What is this code doing?
int i=-10, j=-8, k=-11;
int h = (i>j)?(i>k? i:k):(j>k?j:k);
-8, it is finding highest of 3 given numbers.
-11, it is finding highest of 3 given numbers.
-8, it is finding lowest of 3 given numbers.
it is the logic to find biggest of three given numbers using ternary operator. since -8 is highest, it prints -8.
Back To Top