Ad Code

Responsive Advertisement

enumeration in c language.

Enumerated Data Type (enum) 
It is user defined data type is enumerated data type which is defined as under enum identifier

name{valuel, value2.... Valuen};
The identifier is a user defined enumerated data type which can be used to declare variables that have
one of the values enclosed within the braces. After the definition we can declare variables to be of this
'new 'type as below.

enum identifier V1, V2, V3,………. Vn
The enumerated variables V1, V2, ..... Vn can have only one of the values value1, value2..... value n



Example
main()
{
enum months {Jan=1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec};

enum months month;
/* define 'month' variable of type 'months' *
/
printf("%d\n", month=Sep)
}

Post a Comment

0 Comments