I'm just starting TI-86 BASIC programming with the following guessing game:
:randInt(1,10)→X
:0→A
:Repeat A=X
:Disp "Guess the number"
:Input "between 1 and 10.", A
:End
My understanding of the Repeat
statement is that the block will execute until the condition is true. In my case, I find that the block executes exactly once. That means the value of A
that the user enters is always the same as the random value of X
, which I find hard to believe.
Any idea what I'm doing wrong?
Variables in the TI-86's version of TI-BASIC can be compared using the ==
operator. So the program becomes
:randInt(1,10)→X
:0→A
:Repeat A==X
:Disp "Guess the number"
:Input "between 1 and 10.", A
:End