Yurttas/PL/IL/C/F-mar11/03/04/01/01/enum 10.c
Jump to navigation
Jump to search
1/*
2 Copyright(C) 1998
3 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for EDUCATIONAL purposes
7 and without fee is hereby granted provided that this
8 copyright notice appears in all copies.
9
10 date : January 1, 1998.
11 author : Salih Yurttas.
12
13 enum_10.c / gcc -ansi enum_10.c
14*/
15
16
17int main(int argc, char *argv[]) {
18
19 enum RGB {red, green, blue};
20
21 enum RGB a_color;
22
23 int i;
24
25 printf("\ncolors -\n");
26
27 for(i=0; i<4; i++) {
28 a_color = i;
29
30 switch(a_color) {
31 case red : printf("red = %d\n", a_color);
32 break;
33 case green : printf("green = %d\n", a_color);
34 break;
35 case blue : printf("blue = %d\n", a_color);
36 break;
37 default : printf("\n%d is not a valid color.\n", a_color);
38 }
39 }
40
41}