Hi,
In the Sierra-Bates self tests I'm having difficulty with this question, its q10 from chapter 5
My understanding of this code is as follows:
Inner loop first iteration
j = 0
x = 1 //1 is printed
break not executed
Inner loop second iteration
j = 1
x = 1 //1 again is printed
break condition resolves to true, break is executed so in the outer loop x is moved to next value = 3
So, at this point, does the break statement mean, as the next inner loop iteration is entered, the value of j is
still at 1 or is it now 2 ?
If j's value is indeed 2 and the inner loop iterates, x is printed as 3, and on the next iteration of the inner loop the
condition fails (j becomes 3) does the print statement still run ? Printing x as 3 again. If so giving us 1133 ?
I know it can't be 1 - would that not result in the next element of the outer loop ie. 5 when the answer is:
113399
Hope formatting is better than my last post ! There's a couple more questions on this but for now, thanks !