Curious Conditional Conundrum

I guess you should do it like this to avoid a[16] and L[16] being tested out of bounds:

while( (i < 16 ) && (a[i] >= L[i]) ) { . . .

C++ will not continue to evaluate the expression if an earlier part of it fails.

1 Like