Advanced Program Control 319
13
49: {
50: puts(“\nInvalid choice, try again.”);
51: delay();
52: }
53: }
54: return 0;
55: }
56:
57: /* Displays a menu and inputs user’s selection. */
58: int menu(void)
59: {
60: int reply;
61:
62: puts(“\nEnter 1 for task A.”);
63: puts(“Enter 2 for task B.”);
64: puts(“Enter 3 for task C.”);
65: puts(“Enter 4 for task D.”);
66: puts(“Enter 5 to exit program.”);
67:
68: scanf(“%d”, &reply);
69:
70: return reply;
71: }
72:
73: void delay( void )
74: {
75: long x;
76: for ( x = 0; x < DELAY; x++ )
77: ;
78: }
Enter 1 for task A.
Enter 2 for task B.
Enter 3 for task C.
Enter 4 for task D.
Enter 5 to exit program.
1
Executing task A.
Enter 1 for task A.
Enter 2 for task B.
Enter 3 for task C.
Enter 4 for task D.
Enter 5 to exit program.
6
LISTING13.4 continued
INPUT/
OUTPUT
21 448201x-CH13 8/13/02 11:12 AM Page 319