[Solved] Whats datatypes can be used with enum in c programming and what is the size of enum?


An enumeration is a set of named integer constant values (C 2018 6.2.5 16).

An enumeration constant has type int (C 2018 6.4.4.3 2).

An enumerated type is compatible with char or a signed or unsigned integer type (C 2018 6.7.2.2 4). The choice is implementation-defined, which means it is up to your C compiler.

Thus, the size of an enumeration type depends on your C compiler.

For example, in enum color { red, green, blue };:

  • Each of red, green, and blue is an enumeration constant. It is a constant of type int, and its size is that of an int in your C implementation.
  • The enumeration type, enum color, could be char, signed short, unsigned int, or other possibilities.

4

solved Whats datatypes can be used with enum in c programming and what is the size of enum?