identify the error in the following code segment.
for (int i=0;i<=8;i++)
I think that this does anything. What are your views?
Last edited on
I think you want someone to do your homework for you.
No that was not my intention, I already looked at this and thought it returned nothing and that the error was that it did not call for anything. I just wanted another opinion to see if i was correct.
I think that the error is that it returns 0.
No, the error is this
could you please explain? Is it because since 8is the array and in the loop it said i++ meaning 8+1?
no, the first index of an array is 0. Your array has 8 elements, hence the last valid index is 7. Just count 0...7 (-> 8 indexes)
So your comparison must be i<8 since 8 is alread out ouf bounds
Oh , I forgot that it starts at zero. Thank you so much for your help.