# TI-Basic 84 Programming/Conditional Functions

## If

If, PRGM:CTL:1, is a command that, when it's condition is true, will execute the next line of code. If the condition happens to be false, then the program will skip to the second line of code after the statement.

### Syntax: If

```:If condition
```
• Where condition either an (in)equality (X=3, A>B), or an expression (5+2X), which resolves to be either true (non-zero) or false (zero).

### Ex: If

```PROGRAM:TEMP
:5→X
:If X>3
:Disp "X IS MORE THAN 3"
:Disp "END OF PROGRAM"
```
```prgmTEMP
X IS MORE THAN 3
END OF PROGRAM
```

## Else

Else, PRGM:CTL:3, is a command that, when a previous If statement is not met, will execute the next line of code. If the condition happens to be false, then the program will skip to the second line of code after the statement.

### Syntax: Else

```:If condition
://some action
:Else
://some other action
```
• Else executes when the condition in the If statement is not met.

### Ex: Else

```PROGRAM:TEMP
:5→X
:If X>3
:Disp "X IS MORE THAN 3"
:Else
:Disp "X IS LESS THAN OR EQUAL TO 3"
:Disp "END OF PROGRAM"
```
```prgmTEMP
X IS MORE THAN 3 or X IS LESS THAN OR EQUAL TO 3
END OF PROGRAM
```

## Then

Then, PRGM:CTL:2, is a command used to have a conditional statement (If or Then) execute a block of code as opposed to a single statement.

### Syntax: Then

```:If condition
:Then
://some code
://some more code
:End
```
• Code block is started with a Then statement and ended with the End, PRGM:CTL:7,

Previous: Input
Next: Test Conditions and Logical Operators