Author |
Topic: REPEAT loops (Read 360 times) |
|
chrispc
New Member
member is offline


Posts: 19
|
 |
REPEAT loops
« Thread started on: Jan 11th, 2014, 06:17am » |
|
why doesn't the following give me 1,2...1,3...1,4 up to 1,9 and then 2,1...2,2...2,3 etc. up to 9,9 ? I must be a total idiot. J%=0 K%=0 REPEAT J%=J%+1 REPEAT K%=K%+1 PRINT "(";J%;","K%;") = ";J% UNTIL K%=9 UNTIL J%=9 END
THANKS FOR YOUR INDULGENCE.
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: REPEAT loops
« Reply #1 on: Jan 11th, 2014, 09:37am » |
|
on Jan 11th, 2014, 06:17am, chrispc wrote:why doesn't the following give me 1,2...1,3...1,4 up to 1,9 and then 2,1...2,2...2,3 etc. up to 9,9 ? |
|
Your initialisation of K% is in the wrong place. It should be after the first REPEAT:
Code: J%=0
REPEAT J% += 1
K%=0
REPEAT K% += 1
PRINT "(";J%;","K%;") = ";J%
UNTIL K%=9
UNTIL J%=9
END Richard.
|
|
Logged
|
|
|
|
|