Activity 21.1.
Write a program that does the following:
In the main function, ask the user to enter a number of integers they wish to store, and then allocate memory for a large enough array to hold all of these numbers. Next, call a function
userInput()
, to which you pass the array along with the size of the array, in which the user enters the desired integers which are then saved in the array. Next, your main function should call a printArray()
function (to which you again pass the array and its size), and which prints out all values the user has entered.
Your main function should thus look as follows:
#include <stdio.h>
#include <stdlib.h>
/* prototypes here... */
int main (void) {
int *numbers;
int size;
/* Have user enter size... */
numbers = (int *) malloc(...);
userInput(size, numbers);
printArray(size, numbers);
free(numbers);
return(0);
}
When you are done, please paste your code into the code submission box below: