/* Exercise 9.9 */ #include #define SIZE 10 /* function prototypes */ int *addarrays( int [], int [], int ); void showarrays( int [], int [], int [], int ); main() { int a[SIZE] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int b[SIZE] = {9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; int *c; c = addarrays(a, b, SIZE ); showarrays(a, b, c, SIZE); return 0; } int *addarrays( int first[], int second[], int size ) { int total[SIZE]; int *ptr_total = &total[0]; int ctr = 0; for (ctr = 0; ctr < size; ctr ++ ) { total[ctr] = first[ctr] + second[ctr]; printf("total %d\n", total[ctr]); } return(ptr_total); } void showarrays( int first[], int second[], int third[], int size ) { int ctr = 0; printf("\nFirst\tSecond\tThird"); printf("\n=====\t======\t====="); for (ctr = 0; ctr < size; ctr++ ) { printf("\n%d\t%d\t%d", first[ctr], second[ctr], third[ctr] ); } }