- Related Questions & Answers
- Selected Reading
Enumeration is a user defined datatype in C/C language. It is used to assign names to the integral constants which makes a program easy to read and maintain. The keyword 'enum' is used to declare an enumeration. The following is the syntax of enums. An enumeration provides context to describe a range of values which are represented as named constants and are also called enumerators. In the original C and C enum types, the unqualified enumerators are visible throughout the scope in which the enum is declared. In scoped enums, the enumerator name must be qualified by the enum type name.
C++ Enum Naming
Enumeration is a user defined datatype in C language. It is used to assign names to the integral constants which makes a program easy to read and maintain. The keyword 'enum' is used to declare an enumeration.
Dev C++ Game Programming
Here is the syntax of enum in C language,
The enum keyword is also used to define the variables of enum type. There are two ways to define the variables of enum type as follows.
Here is an example of enum in C language,
Example
Output
Enum Class
In the above program, two enums are declared as week and day outside the main() function. In the main() function, the values of enum elements are printed.