/*------------------------------------------------------------------*/ /* revfn2.c */ /* Author: Bob Dondero */ /* Array and functions. */ /*------------------------------------------------------------------*/ #include enum {ARRAYSIZE = 5}; /*------------------------------------------------------------------*/ static void getNumbers(int piNums[ARRAYSIZE]) /* Read numbers from stdin into aiNums. */ { int i; printf("Enter %d integers:\n", ARRAYSIZE); for (i = 0; i < ARRAYSIZE; i++) scanf("%d", &piNums[i]); } /*------------------------------------------------------------------*/ static void putNumbers(int piNums[ARRAYSIZE]) /* Print the elements of aiNums to stdout in reverse order. */ { int i; printf("The integers in reverse order are:\n"); for (i = ARRAYSIZE - 1; i >= 0; i--) printf("%d\n", piNums[i]); } /*------------------------------------------------------------------*/ int main(void) /* Read ARRAYSIZE integers from stdin, and write them in reverse order to stdout. Return 0. */ { int aiNumbers[ARRAYSIZE]; getNumbers(aiNumbers); printf("\n"); putNumbers(aiNumbers); return 0; }