Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / testsuite / gdb.hp / gdb.compat / average.c
blob25ba2ee6a6c26085661bb7d9815d7379514119a1
1 /* This is a sample program for the HP WDB debugger. */
3 #include <stdio.h>
4 #include <stdlib.h>
6 #ifdef PROTOTYPES
7 extern int sum(int *, int, int);
8 #else
9 extern int sum();
10 #endif
12 #define num 10
14 static int my_list[num] = {3,4,2,0,2,1,8,3,6,7};
16 #ifdef __STDC__
17 void print_average(int *list, int low, int high)
18 #else
19 void print_average(list, low, high)
20 int *list, low, high;
21 #endif
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 */
27 average = total / num_elements;
28 printf("%10.d\n", average);
31 #ifdef __STDC__
32 int main(void)
33 #else
34 main ()
35 #endif
37 char c;
38 int first = 0, last = 0;
39 last = num-1;
41 /* Try two test cases. */
42 print_average (my_list, first, last);
43 print_average (my_list, first, last - 3);
45 exit(0);