To iterate over an enumeration, you can use a for loop. Here's an example that prints all the months:
enum Month {
JANUARY,
FEBRUARY,
MARCH,
APRIL,
MAY,
JUNE,
JULY,
AUGUST,
SEPTEMBER,
OCTOBER,
NOVEMBER,
DECEMBER
};
int main() {
enum Month currentMonth;
for (currentMonth = JANUARY; currentMonth <= DECEMBER; currentMonth++) {
printf("Month: %d\n", currentMonth);
}
return 0;
}