Question: a program that dynamically allocates an array of integers. Obtain the number of integers from the user at runtime. Use that number to dynamically allocate
a program that dynamically allocates an array of integers. Obtain the number of integers from the user at runtime. Use that number to dynamically allocate an array that will hold the user supplied numbers.
Calculate the sum of int values in the lucky array to generate a final GRAND lucky number.
Your solution need include function definitions to satisfy the following prototypes:
int getSize(); // function to validate user input for the size of the array to be dynamically created [1..8]
int *arrayAllocator(int); function that dynamically allocates an array of integers. The function accepts an integer argument indicating the number of elements to allocate. The function should return a pointer to the array.
int getValue(); // function to obtain a lucky number from the user [5..10]
Testing Specification
Provide 1 test run that demonstrates validation of user input as well as the generation of user-supplied lucky numbers at run time.
Example Test Run
Your program display should look something like thisexamplerun (although the values may differ for each student):
/Enter a value [1..8] 0 Enter a value [1..8] 9 Enter a value [1..8] 2 Time to pick your 2 lucky numbers [5..10] Enter a lucky number [5..10]: 6 Enter a lucky number [5..10]: 7 Here are the values in the lucky array: Lucky number 1 has the value 6 Lucky number 2 has the value 7 Your GRAND lucky number is: 13 */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
