initial import
[staff/goc4/2018bti7061.git] / c-5-structuresFiles / examples / enum1.c
1 #include <stdio.h>
2
3 int main(){
4 enum color {black, white, red, green, blue, yellow};
5
6 enum color col1 = black;
7 enum color col2 = white;
8
9 enum color col3 = red;
10
11 printf("Print colors col1=%d, col2=%d, col3=%d\n", col1,col2,col3);
12
13
14 enum color2 {b=-1, w, r, g, bl, y};
15
16 enum color2 col4 = b;
17 enum color2 col5 = w;
18
19 enum color2 col6 = r;
20
21 printf("Print colors col4=%d, col5=%d, col6=%d\n", col4,col5,col6);
22
23 enum color2 background=w,foreground;
24
25 switch(background){
26 b:
27 g:
28 bl:
29 foreground=w;
30 break;
31 w:
32 y:
33 foreground=b;
34 default:
35 foreground=bl;
36 }
37 printf("Background:%d , Foreground: %d\n",background,foreground);
38
39 }