Question: C++ Design and test a program (function and driver) to determine if an array of integers is in ascending order (or not in ascending order).

C++

Design and test a program (function and driver) to determine if an array of integers is in ascending order (or not in ascending order). The function should return an integer value of 1 if all array values are in ascending order, otherwise return a 0. Main function should ask the user to enter n (maximum of 10) integer numeric values, store the n values in an array, then call function (send array to function), then display message (either yes, array values are ascending, or no, array values are not ascending.) Test with several (at least 3) arrays of data for each case. That is, include 3 test cases for ascending and also 3 test cases for not ascending. Each test case should consist of approx. 5 to 10 values.

Note: you will determine if the values in array are ascending or not ascending. Not ascending is not the same as descending. Check with instructor for clarification

Hint: there are 2 approaches to solving this problem: Approach #1) the elements in an array are ascending if every pair of adjacent array elements is ascending (ex: x[i] < x[i+1]); or Approach #2) an array is not ascending if there is at least one case where adjacent array elements are not ascending. Also, for both approaches, be careful not to exceed array bounds (dont access values beyond the end of the array). Hint: Consider function prototype int ascending (int x[ ], int npts);

Another hint: write several lists of random numbers on a sheet of paper and come up with examples of when the values are ascending, not ascending, etc. Use this exercise to create test cases.

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!