Question: You MUST use pointers and dynamic allocation to complete the following exercise to receive points. Write a program that takes a positive integer as input,

You MUST use pointers and dynamic allocation to complete the following exercise to receive points.
Write a program that takes a positive integer as input, indicating the number of floating point values (separated by whitespaces) that will follow.
(1) Create a dynamic integer array with the size equal to the value of the first input integer to store the user input values. If the first input integer is not positive, the program will output "Invalid size!" and exit.
(2) Find and print out the maximum number and minimum number in the entered floating point array.
Ex: if the input is:
54.35.00.252.30.9
the program would output:
The maximum number is 5.0
The minimum number is 0.25
You MUST define and call the following two functions to return the memory addresses of the elements that store the maximum number and minimum number, respectively. Both functions take the dynamically created float array and its size as input.
float* findMaxNumber(float* array, int size);
float* findMinNumber(float* array, int size);
NOTE THAT: you will receive 20 points deduction if you do not release the dynamic array before the end of the program or your program has memory leaking issue during execution.

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 Databases Questions!