Sams Teach Yourself C in 21 Days

(singke) #1
378 Week 2

LISTINGR2.1 week2.c. Week 2’s review listing
1: /*-------------------------------------------------*/
2: /* Program Name: week2.c */
3: /* program to enter information for up to 100 */
4: /* people. The program prints a report */
5: /* based on the numbers entered. */
6: /*-------------------------------------------------*/
7: /*---------------------*/
8: /* included files */
9: /*---------------------*/
10: #include <stdio.h>
11: #include <stdlib.h>
12:
13: /*---------------------*/
14: /* defined constants */
15: /*---------------------*/
16: #define MAX 100
17: #define YES 1
18: #define NO 0
19:
20: /*---------------------*/
21: /* variables */
22: /*---------------------*/
23:
CH 11 24: struct record {
25: char fname[15+1]; /* first name + NULL */
CH 10 26: char lname[20+1]; /* last name + NULL */
27: char phone[9+1]; /* phone number + NULL */
28: long income; /* incomes */
29: int month; /* birthday month */
30: int day; /* birthday day */
31: int year; /* birthday year */
32: };
33:
CH 11 34: struct record list[MAX]; /* declare actual structure */
35:
CH 12 36: int last_entry = 0; /* total number of entries */
37:
38: /*---------------------*/
39: /* function prototypes */
40: /*---------------------*/
41: int main(void);
42: void get_data(void);
43: void display_report(void);

The numbers to the left of the line numbers indicate the day that covers the
concept presented on that line. If you’re confused by the line, refer to the
referenced day for more information.

Note


23 448201x-W2R 8/13/02 11:12 AM Page 378

Free download pdf