program to compare an input string with a list of string in c and use enum to assign code code example
Example 1: enum c
// Changing default values of enum constants
enum suit {
club = 0,
diamonds = 10,
hearts = 20,
spades = 3,
};
Example 2: a enum data type in c with loop
// example program to demonstrate working
// of enum in C
#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;
}
// OUTPUT
0 1 2 3 4 5 6 7 8 9 10 11