Enum Type in C
Level 4132 keystrokes
Defines an enumeration type and uses it with conditional logic.
C code
// Define enum with 3 colors (RED=0, GREEN=1, BLUE=2)1enum Color { RED, GREEN, BLUE };2 // Declare variable of enum type3enum Color c = GREEN;// Enums are integers internally (GREEN = 1)4printf("Color value: %d\n", c);// Compare with the enum constant; the condition is true5if (c == GREEN) {6 printf("It's green!\n");7}Output
Color value: 1 It's green!
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"× 4,× 3(× 3)× 3=× 3{× 2}× 2\× 2:× 1