+ 3
What is the use of enum in c language?
2 Réponses
+ 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};
+ 4
"An enum is a user-defined data type that consists of integral constants. To define an enumeration, keyword enum is used."
Hope this helps! 👍