Question
Hello I need help with this code in c++ please. I appreciate your help. Also if possible I would greatly appreciate it if you could
Hello I need help with this code in c++ please. I appreciate your help. Also if possible I would greatly appreciate it if you could comment and explain just a bit of the logic as it helps me understand what is going on so I can grasp the material. But anyways on the question. I need help creating a program that dynamically allocates an array. that'll display a menu like this
Menu write a function that displays the following menu to the user:
1. Display
2. Sort
3. Shuffle
4. Max
5. Quit
This code has multiple functions the first being a populate function that passes in the user inputted size, and then it will return a dynamically allocated array of that given size and then populate it with random values between 1-100 and then it'll end up returning the array.
The second function is the display function that will pass in a pointer to an array and it's size and then display the contents of the array with 10 of its values per line and having it skip a line after every 10 values
The third function is a swap function that will be used to pass in two int values chosen from the array using reference and then swap their values(this will be mentioned more later)
The fourth is a sort function that passes in a pointer to the array and size, and then will sort the contents of the array in ascending order using the swap function, by using selection or bubble sort.
the fifth is the shuffle function, what this does is pass in a pointer to the array and the size and then end up shuffling the contents of the array repeatedly by swapping two randomly chosen indexes in the given array by using the swap function
the final is the max function that'll pass in a pointer into the array and a size, and it'll go through the entire array and return the maximum value for the array
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started