Recall & Review
beginner
What is an
enum in C?An
enum in C is a way to name a set of integer constants. It helps make code easier to read by giving meaningful names to numbers.Click to reveal answer
beginner
How do you define an enum for days of the week in C?
You write:
enum Day { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; This creates names for numbers starting at 0.Click to reveal answer
intermediate
Can you assign specific numbers to enum members?
Yes. You can set values like
enum Color { Red = 1, Green = 5, Blue = 10 };. Members without assigned values get the next number after the previous one.Click to reveal answer
beginner
How do you use an enum variable in C?
Declare a variable with the enum type, like
enum Day today;. Then assign a value:
today = Monday;. It stores the integer for Monday.
Click to reveal answer
beginner
What is the default starting value of the first enum member if not assigned?
The first enum member starts at 0 by default. Each next member increases by 1 unless specified otherwise.
Click to reveal answer
What value does the first member of an enum have if not explicitly assigned?
✗ Incorrect
By default, the first enum member has the value 0.
How do you declare an enum variable named
color of type enum Color?✗ Incorrect
The correct syntax is
enum Color color; to declare a variable of enum type.If you define
enum Fruit { Apple = 3, Banana, Cherry };, what is the value of Cherry?✗ Incorrect
Cherry gets the next integer after Banana, which is 5.
Which of these is a benefit of using enums?
✗ Incorrect
Enums improve code readability by replacing numbers with meaningful names.
Can enum members have duplicate values?
✗ Incorrect
Enum members can have the same value, but it can cause confusion and is usually avoided.
Explain what an enum is and how it helps in C programming.
Think about how enums replace numbers with names.
You got /3 concepts.
Describe how to assign specific values to enum members and what happens to members without assigned values.
Consider how numbering works inside enums.
You got /3 concepts.