Agenda
What Is C Enumeration?
What Is Enum Used For?
Enum Variable Declaration
Enumeration Example Program
What Is C Enumeration?
What Is C Enumeration?
Enum is a user-defined data type consisting of an integral constant
Syntax:
enum enum_name (list of constant);
What Is Enum Used For?
What Is Enum Used For?
Enum in c programming is used to allocate a name to the integral constant.
Example:
enum fruits {mango, apple, grapes, banana};
User-defined
type
Keyword
Enumerated constant
What Is Enum Used For?
Example:
enum fruits {mango, apple, grapes, banana};
User-defined
type
Keyword
Enumerated constant
0 1 2 3
Enum Variable Declaration
Example:
enum months {Jan, Feb, mar , Apr ,May,June };
User-defined
type
Keyword
Enumerated constant
0 1 6 7
=5 =9
enum month m; //variable declaration
m = mar;
Enum Variable Declaration
Example:
enum months {Jan, Feb, mar, Apr, May, June};
User-defined
type
Keyword
Enumerated constant
0 1 6 7
5 9
enum month
m1 =
m2 =
m2,
m1, m3, m5,
m4, m6;
mar;
Apr;
Enum Variable Declaration
----------- 5
----------- 6
Enumeration Example Program
Enumeration in C

Enumeration in C

  • 2.
    Agenda What Is CEnumeration? What Is Enum Used For? Enum Variable Declaration Enumeration Example Program
  • 3.
    What Is CEnumeration?
  • 4.
    What Is CEnumeration? Enum is a user-defined data type consisting of an integral constant Syntax: enum enum_name (list of constant);
  • 5.
    What Is EnumUsed For?
  • 6.
    What Is EnumUsed For? Enum in c programming is used to allocate a name to the integral constant. Example: enum fruits {mango, apple, grapes, banana}; User-defined type Keyword Enumerated constant
  • 7.
    What Is EnumUsed For? Example: enum fruits {mango, apple, grapes, banana}; User-defined type Keyword Enumerated constant 0 1 2 3
  • 8.
  • 9.
    Example: enum months {Jan,Feb, mar , Apr ,May,June }; User-defined type Keyword Enumerated constant 0 1 6 7 =5 =9 enum month m; //variable declaration m = mar; Enum Variable Declaration
  • 10.
    Example: enum months {Jan,Feb, mar, Apr, May, June}; User-defined type Keyword Enumerated constant 0 1 6 7 5 9 enum month m1 = m2 = m2, m1, m3, m5, m4, m6; mar; Apr; Enum Variable Declaration ----------- 5 ----------- 6
  • 11.