ObjectiveMcq
Print Protected
This page is protected for print. Use the website to view the content.
Which of the following "for" loops can be used instead of the inner for loop so that the output doesn't change?
Correct Answer: D — No change is required
None of the above mentioned "for" loops can be used instead of the inner for loop. Note, for(j = idx + 1; (j < len && j <= arr[idx] + idx); j++) covers the same range as the inner for loop but it produces the wrong output because the indexing inside the loops changes as "j" takes different values in the two "for" loops.