+ 3

What is the use of enum in c language?

23rd Jan 2018, 3:54 AM
Puneet Bhardwaj
Puneet Bhardwaj - avatar
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};
23rd Jan 2018, 4:13 AM
John Wells
John Wells - avatar
+ 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! 👍
23rd Jan 2018, 3:58 AM
Dread
Dread - avatar