Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: AGVolnutt on May 26, 2011, 08:04:53 pm
-
(removed)
-
Whilst editing a program, press PRGM and then press 4
Congratulations! you now have a For( in program!
This is the command for a For loop. The syntax is
For(VAR(A~theta),starting value, end value[, increment]
.code goes here
End
The part in brackets is optional. If you leave it off, the increment is 1.
What a For loop does is it sets VAR to the starting value, executes the code, adds Increment to VAR, then checks to see if VAR is > (< if increment is negative) the ending value, and loops if it isn't.
-
Thanks but...
That's for TI-84. XD
I forgot to mention I'm working with nSpire code.
Sorry.
BUT! I did look up the "For" command in my reference guide. I'll take your advice and be sure to figure out how it works!
Thank you!
-
I think For loop syntax doesn't change much, if at all, between languages, it's a pretty common structure, but it can't hurt to check. Oh, and I forgot to mention that an increment of 0 is never valid
-
SO
I think For loop syntax doesn't change much, if at all, between languages, it's a pretty common structure, but it can't hurt to check. Oh, and I forgot to mention that an increment of 0 is never valid
So I should make sure that my inputted n is +1'd before I the program goes on, right?
-
No, that's not it. In fact, a For loop sets the variable to the starting value at the very beginning.
What I meant was that
For(foo,bar,baz,0
is invalid code in any language, because the increment is 0
-
An increment of zero can be valid in some languages. It will just likely freeze/crash your program unless you manually increment the variable yourself or jump out of the loop. :P