Introduction to Enumeration
Get introduced to enumeration with the help of an interactive example.
What is an enumeration?
During programming, we are often required to store and use values of colors, marital status, etc. This can be done using:
- Strings
- Constants
- Macros
All the above ways have their own limitations, as discussed in the previous lesson. Let’s discuss another data type known as an enumeration.
An enumeration allows you to define your own data type along with the values of a variable that it can store.
Declaring an enumerated data type
The basic syntax for declaring an enumerated data type is given below:
Get hands-on with 1400+ tech skills courses.