/* * An initial program to read values and print them in reverse order. */ #include #include #define MAXVALS 100 /* max number of values we can reverse */ int main() { int table[MAXVALS]; /* array to hold input values */ int n; /* number of values in "table" */ int i; /* index used in writing values */ int next; /* next input value */ n = 0; while (scanf("%i", &next) == 1) { if (n >= MAXVALS) /* Make sure there's room */ { printf("No more room after reading %i values.\n", n); break; } table[n++] = next; } for (i = n - 1; i >= 0; i--) printf("%i\n", table[i]); return EXIT_SUCCESS; }