Let us re-evaluate our sample program.
Without short circuited evaluation, this program won’t work anymore. Just work out the following scenario. a[0] = 2,a[1] = 4,a[2] = -2,a[3] = 7,k = 1. When i = 4, the left condition on line 2 returns false. However, that does not stop the evaluation of the right condition. Which means a[i]≠k will be a[4]≠k, which is an invalid operation!