Recall & Review
beginner
What is an enumeration (enum) in C?
An enumeration is a user-defined type in C that consists of named integer constants. It helps to assign names to integral values, making code easier to read and maintain.
Click to reveal answer
beginner
Why do programmers use enumerations instead of plain integers?
Enumerations give meaningful names to integer values, which improves code clarity and reduces errors by avoiding magic numbers.
Click to reveal answer
intermediate
How do enumerations help in reducing bugs?
By using named constants, enumerations prevent accidental use of wrong values and make it easier to understand what each value represents.
Click to reveal answer
intermediate
Can enumerations improve code maintenance? How?
Yes. When values need to change, you only update the enum definition, and all code using those names automatically uses the new values, making maintenance simpler.
Click to reveal answer
beginner
Give a real-life example where enumerations are useful.
For example, days of the week can be represented as enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday }; This makes code using days easier to read than using numbers 0 to 6.
Click to reveal answer
What is the main benefit of using enumerations in C?
✗ Incorrect
Enumerations provide named constants which make code easier to read and understand.
Which of the following is a correct way to declare an enum for colors?
✗ Incorrect
The correct syntax uses curly braces without assignment or colon.
How does using enums help prevent bugs?
✗ Incorrect
Named constants reduce mistakes caused by using wrong numbers.
If you want to change the value of a named constant, what is the advantage of enums?
✗ Incorrect
Changing the enum definition updates all uses automatically.
Which of these is NOT a reason to use enums?
✗ Incorrect
Enums store integer constants, not strings.
Explain why enumerations are useful in C programming.
Think about how names help understand numbers.
You got /4 concepts.
Describe a simple example where using an enum makes code clearer.
Use something familiar like days of the week.
You got /3 concepts.