Define Enumeration in Computer Programming?
Enumerated types enclose a list of constants that are able to be addressed in integer values.
We can declare variables and types as follows.
enum days
{
mon, tues, ..., sun
} week;
enum days week1, week2;
NOTE: As with arrays first enumerated name has index value 0. So mon has value 0, tues 1, etc.
week1 and week2 are variables.
We can define other values:
enum escapes
{
bell = `\a',
backspace = `\b',
tab = `\t',
newline = `\n',
vtab = `\v',
return = `\r'
};
We can also override the 0 start value:
enum months
{
jan = 1, feb, mar, ......, dec
};
Here it is implied that feb = 2 etc.