Question: Write a C program named enter _ ints.c . The program will allow the user to enter as many ints as they want. It should

Write a C program named enter_ints.c. The program will allow the user to enter as many ints as they want. It should first prompt the user for the number of ints that they will enter. It must then dynamically allocate exactly enough space for the ints using malloc. It should then allow the user to enter them (on a single line or multiple lines). It should then print the contents of the array. Then the memory should be freed. Compile enter_ints.c into an executable named enter_ints. Some example runs are shown below (please match the output formatting exactly, note there is one space after the question mark and not a newline)
Hint: You cannot use scanf, but you can use the getint() function.
Hint2: do not declare a fixed-size array such as int array[count];. You must use malloc.
Note: prior to C99(e.g. in Kernighan book), array sizes needed to be determinable at compile time.
Hint3: The autograder will try to compile enter_ints.c only (it assumes no additional .c files are being used).
$ ./enter_ints (Sample Output)
How many numbers will you enter? 5
135579
array[0]=1
array[1]=3
array[2]=55
array[3]=7
array[4]=9
$ ./enter_ints
How many numbers will you enter? 4
8
6
47
2
array[0]=8
array[1]=6
array[2]=47
array[3]=2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!