I am back at another project and got stuck at a certain point.
During the task I want to compare two elements of an array a[i] and a[i+1].
My problem is that I always get Out of Bound errors for the last number because I think the program also tries to compare it with a[i+1] which is not in the array for the last number.
How can I solve this issue?
Your logic to find whether the array is sorted decreasingly won't work.
If you put number in all the indices, you will find that when you get to the end of your 20‑element array, you will be working withj = 19. If you try to work out whether the next element is less than array, you will end up using array which of course doesn't exist. Try...or...If you have a 20‑element array, you will have 19 comparisons. That is a fencepost number.