OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.hp/] [gdb.compat/] [average.c] - Blame information for rev 24

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
/* This is a sample program for the HP WDB debugger. */
2
 
3
#include <stdio.h>
4
#include <stdlib.h>
5
 
6
#ifdef PROTOTYPES
7
extern int sum(int *, int, int);
8
#else
9
extern int sum();
10
#endif
11
 
12
#define num   10
13
 
14
static int my_list[num] = {3,4,2,0,2,1,8,3,6,7};
15
 
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
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__
32
int main(void)
33
#else
34
main ()
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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.