/* Function to reverse the elements of an array. */ #include #include /* Your mission is to implement the reverse function * in the function declaration below. */ void reverse(int nums[], int n) { /* BEGIN ANSWER */ // ADD YOUR CODE HERE /* END ANSWER */ } /* DO NOT ALTER THE 'main' PROGRAM */ int main(void) { int numbers[100]; int count=0; int newval = 1, i; printf("Enter a list of (at most 100) positive integers.\n"); printf("Use a 0 or a negative int "); printf("to indicate you are finished.\n"); while ((count < 100) && (newval >0)) { scanf("%d", &newval); if (newval>0) { numbers[count] = newval; count++; } } if (count == 0) printf("\nNo positive numbers entered.\n"); else { reverse(numbers, count); printf("\nYour list has been reversed. It is now: \n"); for (i=0; i < count; i++) printf("%d ", numbers[i]); } printf("\n"); return EXIT_SUCCESS; }