c enum code example
Example 1: a enum data type in c
#include<stdio.h>
enum week{Mon, Tue, Wed, Thur, Fri, Sat, Sun};
int main()
{
enum week day;
day = Wed;
printf("%d",day);
return 0;
}
2
Example 2: how to define a enum in c
enum type_of_fuel{ Gasolina, Gasoleo, Hibrido, Eletrico};
Example 3: enum c
enum suit {
club = 0,
diamonds = 10,
hearts = 20,
spades = 3,
};
Example 4: a enum data type in c with loop
#include<stdio.h>
enum year{Jan, Feb, Mar, Apr, May, Jun, Jul,
Aug, Sep, Oct, Nov, Dec};
int main()
{
int i;
for (i=Jan; i<=Dec; i++)
printf("%d ", i);
return 0;
}
0 1 2 3 4 5 6 7 8 9 10 11