Google News
logo
Embedded C - Interview Questions
What do you mean by enumeration in C?
An enum in C is a user-defined data type. It consists set of named constant integers. Using the enum keyword, we can declare an enumeration type by using the enumeration tag (optional) and a list of named integer.
 
Basically, we used the enum to increase the code readability and with enum easy to debug the code as compared to symbolic constant (macro). The most important property of enum is that it follows the scope rule and the compiler automatically assigns the value to its member constant.
 
Note : A variable of enumeration type stores one of the values of the enumeration list defined by that type.
 
Syntax of enum :
enum Enumeration_Tag { Enumeration_List };
The Enumeration_Tag specifies the enumeration type name.
 
The Enumeration_List is a comma-separated list of named constant.
 
Example :
enum FLASH_ERROR { DEFRAGMENT_ERROR, BUS_ERROR};
Advertisement