Syntax error on simple If Else
ti-basic
Solution
TI-Basic is often rather picky about the syntax of if statements.
There are three general formats for an If statement.
Single Statement If
:If <boolean>
:<expression>
Note that `<expression>` consists of exactly one line of code.
Multi Statement If
:If <boolean>
:Then
:<expresion>
:<expresion>
:End
As opposed to the first option, this option can contain any number of lines of code after the `If`.
If Else
:If <boolean>
:Then
:<expresion>
:<expresion>
:Else
:<expresion>
:<expresion>
:End
As with the previous option, any number of statements can be put after the `If` and after the `Else`.
You are obviously trying to use an if else statement. The correct syntax for this is:
:If B
:Then
:C->B
:B->remainder(A,B)
:A->B
:prgmGCD2
:Else
:Disp A
:End
Problem
I get an error at the 'Else' on a TI-84 Plus. I can't figure out why this doesn't work. I'm writing a GCD program just as an exercise in programming a TI calculator. It's recursive (or as recursive as TI-BASIC gets). ``` If B=0 Disp A Else C->B B->remainder(A,B) A->B prgmGCD2 ```