Commit | Line | Data |
---|---|---|
8e260d52 DT |
1 | /* This is a sample program for the HP WDB debugger. */ |
2 | ||
3 | #include <stdio.h> | |
4 | ||
5 | #define num 10 | |
6 | ||
7 | static int my_list[num] = {3,4,2,0,2,1,8,3,6,7}; | |
8 | ||
9 | #ifdef __STDC__ | |
10 | void print_average(int list[], int low, int high) | |
11 | #else | |
12 | void print_average(list, low, high) | |
13 | int list[], low, high; | |
14 | #endif | |
15 | { | |
16 | int total, num_elements, average; | |
17 | total = sum(list, low, high); | |
18 | num_elements = high - low; /* note this is an off-by-one bug */ | |
19 | ||
20 | average = total / num_elements; | |
21 | printf("%10.d\n", average); | |
22 | } | |
23 | ||
24 | #ifdef __STDC__ | |
25 | int main(void) | |
26 | #else | |
27 | main () | |
28 | #endif | |
29 | { | |
30 | char c; | |
31 | int first = 0; | |
32 | int last = num-1; | |
33 | ||
34 | /* Try two test cases. */ | |
35 | print_average (my_list, first, last); | |
36 | print_average (my_list, first, last - 3); | |
37 | foo: | |
38 | exit(0); | |
39 | } |