]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.hp/gdb.compat/average.c
daily update
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.hp / gdb.compat / average.c
CommitLineData
7be570e7
JM
1/* This is a sample program for the HP WDB debugger. */
2
3#include <stdio.h>
4#include <stdlib.h>
5
6#ifdef PROTOTYPES
7extern int sum(int *, int, int);
8#else
9extern int sum();
10#endif
11
12#define num 10
13
14static int my_list[num] = {3,4,2,0,2,1,8,3,6,7};
15
16#ifdef __STDC__
17void print_average(int *list, int low, int high)
18#else
19void print_average(list, low, high)
20int *list, low, high;
21#endif
22 {
23 int total = 0, num_elements = 0, average = 0;
24 total = sum(list, low, high);
25 num_elements = high - low; /* note this is an off-by-one bug */
26
27 average = total / num_elements;
28 printf("%10.d\n", average);
29 }
30
31#ifdef __STDC__
32int main(void)
33#else
34main ()
35#endif
36{
37 char c;
38 int first = 0, last = 0;
39 last = num-1;
40
41 /* Try two test cases. */
42 print_average (my_list, first, last);
43 print_average (my_list, first, last - 3);
44
45 exit(0);
46}