You must have seen the word enum if you have done any programming.As we all know there is 32 keyword in c, enum is also one of them..
But what is this actually?
Just as there is a user-defined function in every programming, in the same way, there is a user-defined function as well as a user-defined data type.
This means that an enum is a user-defined data type in C that consists of a set of named integer constants. Also known as Enumerations.
General form:
enum identifier_name {value1, value2,…….valuen};
Here.. identifier_name is a user-defined enumerated data type that can be used to declare a variable.
enum DaysOfWeek {
SUNDAY,
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY
};
Here names of weeks like SUNDAY, MONDAY… are known as enumeration constant. By default, the first constant (SUNDAY) is assigned the value 0, and subsequent constants are assigned values in increasing order.