Ternary Operator in C
Level 266 keystrokes
Uses the ternary operator to take the larger of a (5) and b (10) and prints the maximum, 10.
C code
// The two values to compare: a = 5 and b = 101int a = 5, b = 10;// If a > b the result is a, otherwise b; 5 > 10 is false, so max gets b (10)2int max = (a > b) ? a : b;// Prints the maximum, 103printf("%d\n", max);Output
10
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:× 1?× 1\× 1%× 1