C Programming Enumeration
C Programming Enumeration
An enumeration is a user-defined data type consists of integral constants and each integral constant is give a
name. Keyword enum is used to defined enumerated data type.
enum type_name{ value1, value2,...,valueN };
Here, type_name is the name of enumerated data type or tag. And value1, value2,....,valueN are values of
type type_name.
By default, value1 will be equal to 0, value2 will be 1 and so on but, the programmer can change the default
value.
// Changing the default value of enum elements
enum suit{
club=0;
diamonds=10;
hearts=20;
spades=3;
};
Output
4 day
You can write any program in C language without the help of enumerations but, enumerations helps in writing
clear codes and simplify programming.