Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE HELP IN C++ (DUE MIDNIGHT) I am having trouble debugging my code and matching it to the output. I have been staring at my
PLEASE HELP IN C++ (DUE MIDNIGHT)
I am having trouble debugging my code and matching it to the output. I have been staring at my screen for hours and cannot figure this out, can someone please help me and also explain the answer. My output keeps outputting something off, and I'm not sure where my error is. Thank you so much
MY CODE:
THE ASSIGNMENT INSTRUCTIONS:
Autograder output:
Enter non-negative integers. End with 1:1115685265541 111568526554 Array is not sorted Enter a value to insert: 5 1115685265545 Enter a value to delete: 52 11156865545 5511155465 Array is sorted Reversing the Array is: 5 5 11 155465 ArrayP7ay 2023.cpp Instructions: You will be building array functions to read an array, insert, delete, sort, reverse. The array contains integers. Please: - Write one function at a time. Test it to make sure it really works, and then move on to next function. - Write comments to: 1) document your algorithms and design, including input parameters, return values and known limitations 2) make your code readable to others Starter Code: Follow ToDo instructions, in order. \#include using namespace std; int main() f const int CAPACITY =20; int numArray[CAPACITY]; // an int array with a given CAPACITY // numarray can be partially filled, (so use numArrayelems below) int numArrayelems=0; // the array is initially empty, i.e., contains 0 elements // Actual number of elements stored // 1. ToDo: Build and call fillarray function // fills an int array with values entered by the user. // Stops reading when the user inputs 1 or CAPACITY is reached. // Use this prompt: "Enter non-negative integers. End with -1: " // 2. ToDo: Build and call printArray function. // printArray should print elements separated by a space, ending with newline // 3. ToDo: Build IsSorted function. // return a Boolean, indicating if the array is sorted (low to high). // 4. If the array is sorted, print "Array is sorted \ n" s // otherwise print "Array is not sorted " // 5. ToDo: Define and Build your own function to: // Read a value from the user and insert it into the array // Use this prompt: "Enter a value to insert: " // If the array is sorted, put it in the proper location, keeping the order // Consider making a function to determine the proper location // The proper location has a value >= the new value. // Push all the other numbers to the right to add this value // If the array is not sorted, you may put it at the end. // 6. ToDo: Call printArray 552 2. Sorted Add 31 Remove 62 Input 2: 51015202530354045505562651 3162 3. Not Sorted Add 43 Remove 17 (not there) Not Sorted Add 5 Remove 52 Correctness Actual exit status: Output: Output Diffs Output Diffs Output DiffsStep 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