Question: Write a program in C that does the following: Using the command malloc, dynamically allocate a block of memory capable of storing a user-input quantity
Write a program in C that does the following:
- Using the command "malloc," dynamically allocate a block of memory capable of storing a user-input quantity of floating point variables.
- Handle malformed user input appropriately.
- After allocating the memory, use pointers to step through the array and print the values encountered at each slot.
- What values do you see? The numbers should seem garbled or random. Explain why this is.
- Use pointers to step through the array again and, at each location, store a random floating point number between 1 and 10. Verify that this was successful by stepping through the array a third time and printing the numbers from the dynamic array to the screen.
- De-allocate the array when complete.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
