An enumeration is a user-defined data type that consists of integral constants. To define an enumeration, keyword enum
is used.
#include < stdio.h >
enum week { sunday, monday, tuesday, wednesday, thursday, friday, saturday } ;
int main()
{
enum week today;
today = wednesday;
printf ( " Day % d " , today + 1 ) ;
return 0;
}
Example 2
#include < stdio.h >
void main ( )
{
int i ;
enum month { JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT,NOV, DEC } ;
clrscr ( ) ;
for ( i = JAN ; i < = DEC ; i++ )
printf ( " \ n % d ", i ) ;
getch ( ) ;
}