Enumerated
Types
Enumerated
types contain a list of constants that can be addressed in integer values.
We
can declare types and variables 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, and so on.
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};
No comments:
Post a Comment