Question: Suppose we expect the elements of an array to be in order. However, to be safe, we want our program to test the array and

Suppose we expect the elements of an array to be in order. However, to be safe, we want our program to test the array and issue a warning in case it turns out that that some elements are out of order. The following code is supposed to do that but there is an error. Can you find it and correct it?

double a [10];

--some code to fill the array

for (int index = 0; index < 10; index++)

if (a[index] > a[index + 1])

cout << array elements << index << and << index + 1 << are out of order << endl;

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!