Home > Electronics Tutorials > C Language Tutorial > Identifiers - Enumerated Tags

C Language Programming Library Reference Guide

Identifiers - Enumerated Tags

Enumeration allows a series of constant integers to be easily assigned. The format to create a enumeration specifier is: enum identifier {enumerator-list};
Identifier is a handle for identification, and is optional.
Enumerator-list is a list of variables to be created. They will be constant integers. Each variable is given the value of the previous variable plus 1. The first variable is given the value of 0. Examples: enum {joe, mary, bob, fran};
Creates 4 variables. The value of joe is 0, mary is 1, bob is 2, and fran is 3.

enum test {larry, floyd=20, ted};
Creates 3 variables with the identifier test. The value of larry is 0, floyd is 20, and ted is 21.
Note: To report broken links or to submit your projects, tutorials please email to Webmaster