Ternary Min Value in C
Level 270 keystrokes
Uses the ternary operator to take the smaller of x (8) and y (3) and prints "Min: 3".
C code
// The two values to compare: x = 8 and y = 31int x = 8, y = 3;// If x < y the result is x, otherwise y; 8 < 3 is false, so min gets y (3)2int min = (x < y) ? x : y;// Prints "Min: 3"3printf("Min: %d\n", min);Output
Min: 3
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C code and how often they appear.
;× 3=× 3,× 2:× 2"× 2(× 2)× 2?× 1\× 1%× 1