Enumeration
Enumeration is a user define datatype in C programming. The “enum” keyword is used to define new enumeration types in C. An enumeration is used to define a constant set of values. Such as, the days of the week can be defined as an enumeration.
Syntax
enum flag{constant1, constant2 ....... };
Declaration
enum week{ Mon, Tue, Wed, Thur, Fri, Sat, Sun};
Initialization
enum week day;
Example
#include<stdio.h> enum week { Mon, Tue, Wed, Thur, Fri, Sat, Sun }; int main() { num week day; day=Fri; printf(“%d”,day); return 0; } |