If-Else Statement in C
Level 278 keystrokes
Uses if-else to check whether num is even: 7 % 2 is 1, not 0, so the else branch runs and prints "Odd".
C code
// The number to classify is 71int num = 7;// A number is even if dividing by 2 leaves remainder 0; 7 % 2 is 1, so this is false2if (num % 2 == 0) { // Skipped here, because the condition is false3 printf("Even\n");// else runs its block when the if condition is false4} else { // This branch runs and prints "Odd"5 printf("Odd\n");6}Output
Odd
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.
"× 4;× 3(× 3)× 3=× 3{× 2}× 2\× 2%× 1