0
0
Cprogramming~10 mins

Enum usage in C - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare an enum named Color.

C
enum Color { RED, [1], BLUE };
Drag options to blanks, or click blank then click option'
AGREEN
Byellow
Corange
Dpurple
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase names for enum members.
Forgetting to separate enum members with commas.
2fill in blank
medium

Complete 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'
AGreen
BRED
Cred
Dblue
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase enum member names.
Using undeclared enum members.
3fill in blank
hard

Fix 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'
AWEDNESDAY
Bwednesday
CThursday
DFRIDAY
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or mixed case names.
Skipping enum members in sequence.
4fill in blank
hard

Fill 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'
ASize
BColor
Csize
DShape
Attempts:
3 left
💡 Hint
Common Mistakes
Using inconsistent names for enum and variable.
Using lowercase for enum name.
5fill in blank
hard

Fill 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'
ALevel
BMEDIUM
C10
DSize
Attempts:
3 left
💡 Hint
Common Mistakes
Not matching enum name and variable type.
Using wrong values for enum members.