/* Allocate space for a integer array dynamically, request user input, and then print the array backwards. */ #include #include #define N 10 int main(void) { int *a, i; //allocate space for N integers a = malloc(N * sizeof(int)); if (!a){ printf("Out of memory!\n"); return 1; } //request user input printf("Please enter %d intergers:\n", N); for(i=0; i < N; i++) scanf("%d", &a[i]); //print the array backwards printf("print integers backwards:\n"); for(i=N-1; i >= 0; i--) printf("%d ", a[i]); printf("\n"); //release allocated memory free(a); return 0; }