]>
git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.hp/average.c
1 /* This is a sample program for the HP WDB debugger. */
7 static int my_list
[num
] = {3,4,2,0,2,1,8,3,6,7};
10 void print_average(int list
[], int low
, int high
)
12 void print_average(list
, low
, high
)
13 int list
[], low
, high
;
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 */
20 average
= total
/ num_elements
;
21 printf("%10.d\n", average
);
34 /* Try two test cases. */
35 print_average (my_list
, first
, last
);
36 print_average (my_list
, first
, last
- 3);