+ 3
What is the use of enum in c language?
2 Answers
+ 9
It allows you to create your own names for integer data. They can be used anywhere an integer can be used.
enum direction {north, east, south, west};
int d = north;
printf("%d\n", d);
outputs 0
They can be assigned exact values instead of sequential ones.
enum data {one = 1, zero = 0, ten = 10};