c++ 1. Write a function with the following prototype: bool insert (int value, int intArray[ ], int & numberOfValidEnties, int size); Precondition is that the
c++
1. Write a function with the following prototype:
bool insert (int value, int intArray[ ], int & numberOfValidEnties, int size);
Precondition is that the first numberOfValidEntries values in intArray (length given by size) are in sorted order. If numberOfValidEntries is 0 or 1, obviously, there is no ordering, but if numberOfValidEntries is greater than 1, the valid numbers in the array in sorted order from smallest to largest.
If there is still room in the array, the function will insert value so that the sorted order is preserved, increment numberOfValidEntries by 1, and return true. If it is not possible to add another value into the array, the array and numberOfValidEntries will remain unchanged. and the function will return false.
2. Write a function with the following prototype:
bool delete (int value, int intArray[ ], int & numberOfValidEnties);
The precondition is the same as for the insert function.
The delete function will look for value in the array, and if found, it will delete it by moving all valid entries below it up by one, decrement numberOfValidEnties, and return true. If the value is not found, it returns false and the array and numberOfValidEntries remain unchanged.
3. Write a function called print with 2 parameters, an integer array and the number of valid entries in the array, and prints out the valid entries
4. Write a main program that starts out with an integer array of size 10 with no valid entries. Write an interactive menu in which the user can keep choose to insert, delete, or print until the choice to quit is chosen.
Use your program to thoroughly test your functions.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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