enum : Enumerated data type

Enumerated data type :

  • enum is called the enumerated data type in c.
  • It is a user defined data type.
  • It consists of integer constants where each constant is given a name.
  • Syntax:
    enum name{ value1, value2, value3, ……};
  • Default values of value1 is 0, value2 is 1, value3 is 2 ……. or they can be initialised at the same time.

e.g.

Output:

Here, enumerated data type is created with name week which contains the values of weekdays. The default values of mon=0,tue=1 and similarly for others.

Leave a Reply

Your email address will not be published. Required fields are marked *