Solution for Exercise 12-23

ex1223

#include <stdio.h>

#define SIZE 5

void showarray(int array[]);

int main()
{
    int n[] = { 1, 2, 3, 5, 7 };

    puts("Here's your array:");
    showarray(n);
    return(0);
}

void showarray(int array[])
{
    int x;

    for(x=0;x<SIZE;x++)
        printf("%d\t",array[x]);
    putchar('\n');
}

Notes

* Array arguments to a function need not be prototyped using the variable name, as is shown on Line 5. Instead you could write:

The above declaration informs the compiler that the showarray() function eats an array of integers. That's good! You still, however, need to name the array when the function is declared (at Line 16).