#include #include #define ONE 1 // The usual use of enum. Values start at 0 and are assigned sequentially. // (So, GREEN == 0 and BLUE == 1.) typedef enum color_t {GREEN, BLUE} Color; // The following enum is a bad idea. It is NOT composed of 10, 11, 12, 13, 14. // It simply defines TEN==10, ELEVEN==11, THIRTEEN==13, and RANGE_MAX==14 typedef enum {TEN=10, ELEVEN, THIRTEEN=13, RANGE_MAX} Range; int main(int argc, char *argv[]) { printf("Enumerating Color's: "); for ( Color color = GREEN; color <= BLUE; color += ONE) printf("%d ", color); printf("\n"); printf("Enumerating Range: "); for ( Range i=TEN; i<=RANGE_MAX; i++ ) printf("%d ", i); printf("\n"); // You'd probably like this to be an error, but it isn't! printf("Mixed use: "); for ( Color color = GREEN; color < RANGE_MAX; color++ ) printf("%d ", color); printf("\n"); return EXIT_SUCCESS; }