Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an enum named Color.
C
enum Color { RED, [1], BLUE }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names for enum members.
Forgetting to separate enum members with commas.
✗ Incorrect
The enum Color includes RED, GREEN, and BLUE as its members.
2fill in blank
mediumComplete the code to assign the enum value to a variable.
C
enum Color myColor = [1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase enum member names.
Using undeclared enum members.
✗ Incorrect
Enum members are case-sensitive and usually uppercase. Assigning RED to myColor is correct.
3fill in blank
hardFix the error in the enum declaration by completing the blank.
C
enum Days { MONDAY = 1, TUESDAY, [1] }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or mixed case names.
Skipping enum members in sequence.
✗ Incorrect
Enum members should be uppercase and consistent. WEDNESDAY fits correctly after TUESDAY.
4fill in blank
hardFill both blanks to create an enum and assign a value.
C
enum [1] { SMALL, MEDIUM, LARGE }; enum [2] size = MEDIUM;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent names for enum and variable.
Using lowercase for enum name.
✗ Incorrect
The enum is named Size, and the variable size is declared with that enum type.
5fill in blank
hardFill all three blanks to define an enum with explicit values and assign a variable.
C
enum [1] { LOW = 1, [2] = 5, HIGH = [3] }; enum Level current = MEDIUM;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not matching enum name and variable type.
Using wrong values for enum members.
✗ Incorrect
The enum Level has LOW=1, MEDIUM=5, and HIGH=10. The variable current is assigned MEDIUM.