I hope this helps…
x <- 0
REPEAT_UNTIL( x = 3 ){ <----Loop1
y <- 0
x <- x+1
REPEAT_UNTIL ( y = 3 ){ <-----Loop2
y <- y+1
DISPLAY( x + ", " + y)
}
}
As we enter Loop1 the first time X is 0. Inside Loop1 y is set to 0 and X is set to 1. Loop2 then executes.
First time in the loop2:
Y set to 1 and “1, 1” is displayed
Second time through Loop2:
Y is set to 2 and “1, 2” is displayed
Third time through Loop2:
Y is set to 3 and “1, 3” is displayed
Y is 3 so Loop2 terminates.
Second time through Loop1:
Y is set back to 0
X is set to 2
First time in the loop2:
Y set to 1 and “2, 1” is displayed
Second time through Loop2:
Y is set to 2 and “2, 2” is displayed
Third time through Loop2:
Y is set to 3 and “2, 3” is displayed
Y is 3 so Loop2 terminates.
Third time through Loop1:
Y is set back to 0
X is set to 3
First time in the loop2:
Y set to 1 and “3, 1” is displayed
Second time through Loop2:
Y is set to 2 and “3, 2” is displayed
Third time through Loop2:
Y is set to 3 and “3, 3” is displayed
Y is 3 so Loop2 terminates.
X is 3 so Loop1 terminates.
So the outputs were:
1, 1
1, 2
1, 3
2, 1
2, 2
2, 3
3, 1
3, 2
3, 3