Hi guys I'm having trouble understanding how i = 5,I actually wrote the algorithm myself which is pretty funny,anyway in the for loop i will run less than size-1 lets say I use the word hello the size will be 5, but the outer for loop will only execute three times and i will only be incremented 3 times so how is it that when both the for loops finish I ends up being 5,I thought it would be 3?
Given "size" a value of 5 the outer for loop will run from zero to three as it should. When "i" equals four the condition fails because four is not less than four. The for loop will only use the elements of the array from zero to three, but the value if "i" will always be one more than you used when the loop is finished.
At line 27 the program prints 4 as it should. The full output I get is: