What Are Enumerators in C?
An enumerator is a named constant that belongs to an enumeration.
An enumeration (enum) is a user-defined data type that consists of a fixed set of named integer constants.
For example:
c
enum Weekday
{
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY,
SUNDAY
};
Here, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, and SUNDAY are all enumerators.
What Is the Difference Between enum and Enumerator?
Although the terms enum and enumerator are often used interchangeably, they refer to different parts of an enumeration in C.
enum is the keyword used to define a new enumeration type.- An enumerator is an individual named constant declared inside that enumeration.
For example:
c
enum Color
{
RED,
GREEN,
BLUE
};
In this example, enum is the keyword that creates the Color enumeration, while RED, GREEN, and BLUE are the enumerators, each representing an integer constant. By default, they are assigned the values 0, 1, and 2, respectively.
| Term | Description |
|---|
| enum | A keyword used to define an enumeration type. |
| Enumerator | A named integer constant declared inside an enum. |
Simply put, an enum is the container, while the enumerators are the named values stored inside it.

Why Use Enumerators?
Using enumerators makes programs easier to read than using numeric values.
Instead of writing:
You can write:
This clearly explains the purpose of the value. Benefits include:
- Better readability
- Easier debugging
- Improved maintenance
- Reduced coding errors
- Organized constant values
Syntax of Enumerators in C
The general syntax is:
c
enum EnumName
{
Enumerator1,
Enumerator2,
Enumerator3
};
Example:
c
enum Color
{
RED,
GREEN,
BLUE
};
How Enumerators Work
By default, the compiler assigns integer values beginning from 0.
c
enum Color
{
RED,
GREEN,
BLUE
};
Equivalent values:
| Enumerator | Value |
|---|
| RED | 0 |
| GREEN | 1 |
| BLUE | 2 |
Default Enumerator Values
Every new enumerator increases by one.
c
enum Number
{
ONE,
TWO,
THREE,
FOUR
};
Output values: ONE = 0, TWO = 1, THREE = 2, FOUR = 3
Assigning Custom Values
You can assign custom integer values.
c
enum Status
{
SUCCESS = 1,
WARNING = 5,
ERROR = 10
};
Values become: SUCCESS = 1, WARNING = 5, ERROR = 10
Mixed Enumerator Values
If one value is assigned, the following values increase automatically.
c
enum Level
{
LOW = 2,
MEDIUM,
HIGH
};
Result: LOW = 2, MEDIUM = 3, HIGH = 4
Can Enum Values Be Changed in C?
No. Enumerator values are constants, which means they cannot be modified after they are defined. Once an enumeration is declared, each enumerator retains its assigned integer value throughout the program.
c
enum Status
{
SUCCESS = 1,
ERROR = 2
};
SUCCESS = 3; // Error: Enumerator values cannot be changed
However, you can change the value stored in an enum variable by assigning it a different enumerator.
c
enum Status state = SUCCESS;
state = ERROR; // Valid
Key points:
- Enumerator values are constant and cannot be modified.
- You can assign different enumerators to an enum variable.
- To use different numeric values, define them when declaring the enumeration.
Enum Variables
You can declare variables using an enum.
c
enum Color
{
RED,
GREEN,
BLUE
};
enum Color selectedColor;
selectedColor = GREEN;
How to Use enum in C
Using an enum in C involves three simple steps: define an enumeration, declare an enum variable, and assign one of its enumerators to the variable. This approach makes your code more readable and eliminates the need to use hardcoded numeric values.
c
#include
enum Color
{
RED,
GREEN,
BLUE
};
int main()
{
enum Color selectedColor = GREEN;
printf("Selected color value: %d", selectedColor);
return 0;
}
Steps to Use an enum
- Define an enumeration using the
enum keyword. - Add meaningful enumerators inside the enumeration.
- Declare a variable of the enum type.
- Assign one of the enumerators to the variable.
- Use the variable in your program just like any other data type.
This method improves code readability, makes programs easier to maintain, and helps avoid using unexplained numeric constants throughout your code.

Enumerator Examples in C
Example 1: Basic Enumerator Program
c
#include
enum Day
{
MONDAY,
TUESDAY,
WEDNESDAY
};
int main()
{
enum Day today = TUESDAY;
printf("%d", today);
return 0;
}
Output: 1
Example 2: Printing Enumerator Values
c
#include
enum Fruits
{
APPLE,
MANGO,
ORANGE
};
int main()
{
printf("%d\n", APPLE);
printf("%d\n", MANGO);
printf("%d\n", ORANGE);
return 0;
}
Output:
Example 3: Custom Enumerator Values
c
#include
enum ErrorCode
{
OK = 100,
INVALID = 200,
FAILED = 300
};
int main()
{
printf("%d", FAILED);
return 0;
}
Output: 300
Practical Applications of Enumerators in C
Enumerators are commonly used in:
- Days of the week
- Months
- Error codes
- Device states
- Traffic light systems
- User roles
- Menu options
- Operating modes
- Communication protocols
- Embedded systems
Advantages of Enumerators
Improves Readability
Named constants are easier to understand than numbers.
Makes Code Easier to Maintain
Updating an enum is simpler than changing multiple numeric values.
Reduces Errors
Developers avoid using incorrect integer constants.
Organizes Related Constants
Related values remain grouped together.
Improves Debugging
Named values are easier to identify during development.
Limitations of Enumerators
- Enumerator values are integers only.
- Enumerators cannot store strings or floating-point values.
- Enumeration names should be unique within their scope.
- They do not provide strict type safety in standard C.
Common Mistakes
Using Magic Numbers
Instead of:
Use:
Duplicate Enumerator Names
Avoid defining identical enumerator names within the same scope.
Unclear Naming
Prefer descriptive names such as ERROR_TIMEOUT instead of E1.
Enumerators vs Macros
| Feature | Enumerators | Macros |
|---|
| Type | Integer constants | Text replacement |
| Readability | High | Moderate |
| Debugging | Easier | Harder |
| Scope | Enumeration | Global after preprocessing |
| Maintenance | Easy | Less convenient |
When Should You Use Enumerators?
Enumerators are ideal when:
- Defining a fixed set of related constants
- Replacing numeric literals
- Representing program states
- Managing status codes
- Improving program readability

Conclusion
Enumerators in C provide a simple and effective way to define meaningful names for related integer constants. By replacing hardcoded numeric values with descriptive identifiers, enumerators make programs more readable, maintainable, and less prone to errors. Whether you’re developing basic C applications or working on embedded systems, using enumerators helps organize constants, simplify logic, and improve overall code quality. Understanding how to declare, assign values, and apply enumerators effectively is an essential step toward writing clean and professional C programs.