+ 1
Could anyone please help me understand the error in this code?
3 Answers
+ 2
for(int i=0 ; i<(i+m)-1;i++) here condition i < (I+m) -1 will never end condition...
edit:
Learnerš„
also this will raise error
int diff=chocs[(i+m)-1]-chocs[i];
when I=5 , then chocs[5+7-1] => chocs[11] , 11 index is out of bounds for array length 11.
+ 2
First of all thank you so much Jayakrishnaš®š³ for always giving fast replies!
I truly appreciate your help!
But would you mind elaborating it?
+ 1
Oh. Already added about when raising error in previous reply as edit.
And if you are about condition then,
i < i + m -1 here condition for any value of i, in each iteartion it increase by i++ so it will be like
0 < 0+7-1 => 0<6 true
1 < 1+7-1 => 1<7 true
2 < 2+7-1 => 2<8 true
Hope it clears now.. ! ?...Learnerš„