Which for loop has range of similar indexes of 'i' used in for (i = 0; i < n; i++)?
- A.for (i= n; i>0; i--)
- B.for (i=n-1; i>0; i--)
- C.for (i = 0; i = 0; i--)
- D.for (i=n-1; i>-1; i--)
Show answer
Answer: D. for (i=n-1; i>-1; i--)
Both loops iterate over indices from n-1 down to 0 (all valid indices from 0 to n-1).