Enum
Enum
ENUM
Enumeration or Enum in C is a special kind of data type defined by the user. It
consists of constant integrals or integers that are given names by a user. The use of
enum in C to name the integer values makes the entire program easy to learn,
understand, and maintain by the same or even different programmer.
we can use an Enum type when you need a fixed set of pre-defined constant
values that are known at the compile-time itself. Examples can be days of the
week, seasons of the year, etc. The following characteristics make enum a 'special'
class: enum constants cannot be overridden.
// Or
// of enum in C
#include<stdio.h>
int main()
day = Wed;
printf("%d",day);
Output:
In the above example, we declared “day” as the variable and the value of “Wed”
is allocated to day, which is 2. So as a result, 2 is printed.
example program to demonstrate working
// of enum in C
#include<stdio.h>
int main()
int i;
Output:
0 1 2 3 4 5 6 7 8 9 10 11
#include <stdio.h>
int main()
Output:
1 2 5 6 10 11 12