What is an enum in C?
#include <stdio.h>
enum Day { MON, TUE, WED };
int main(void) {
enum Day d = TUE;
printf("%d\n", d);
return 0;
}
Output:
Output of the above program is
1
Names make the code easy to read. You can also set values, like enum Level { LOW = 1, HIGH = 10 };. See C enum.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |