<!-- PDF page 17 -->

**1 < 0**\
**0 <-2**

are *false*.

> means *is greater than*, and is just like < but the other way round. You can remember which is which, because the thin end points to the number that is supposed to be smaller.

<= means *is less than or equal to,* so that it is like < except that it is true even if the two numbers are equal: thus **2<=2** is true, but **2<2** is false.

>= means *is greater than or equal to* and is similarly like >.

<> means *is not equal to*, the opposite in meaning to =.

The remaining operators are explained in length in *Chapter 6 – Expressions*.

Mathematicians usually write <=, >= and <> as ≤, ≥ and ≠. They also write things like **2<3<4** to mean **2<3** and **3<4**, but this is not possible in *NextBASIC*.

Line 40 compares **a** and **b**. If they are equal then the program is halted by the **STOP** command. The report at the bottom of the screen **9 STOP, statement, 30:3** shows that the third statement, or command, in line 30 caused the program to halt, i.e. **STOP**.

Line 50 determines whether **b** is less than **a**, and line 60 whether **b** is greater than **a**. If one of these conditions is true then the appropriate comment is printed, and the program works its way to line 70 which tells the computer to go back to line 30 and start all over again. The **CLS** command in line 20 clears the screen to stop the other person seeing what you put in.

Note: in some versions of BASIC the **IF** statement can have the form:

**IF** *condition* **THEN** *line number*

This means the same as:

**IF** *condition* **THEN GO TO** *line number/label*

### ELSE

By adding the optional **ELSE** clause, more complex decisions can be made. This instructs the computer to run another set of commands if the **IF...THEN** test turns out to be false. It is important to note that, unlike some other implementations of BASIC, **ELSE** must follow a colon within a statement line; for instance:

```
IF number<0 THEN PRINT "Negative number":
ELSE PRINT "Positive number"
```

In the example above, if the condition is true (that is, the number is less than zero) then **Negative number** will be printed. If not, then **Positive number** will be printed on screen. But what if you for example wanted a third option to tell if the number is zero? You could use the ability to "nest" **IF...THEN** statements and use the **ELSE** clause to do so. Lets' rewrite the above:

```
IF number<0 THEN PRINT "Negative number":
ELSE IF number>0 THEN PRINT "Positive
number": ELSE PRINT "The number is zero
```

You should see in the above that it is possible to execute a further **IF...THEN** statement if the condition in the original one was false. *NextBASIC* will work through the **IF...THEN** statements until it finds a condition that is true, and will execute that. If no conditions are true, then it will attempt to execute the final **ELSE**. More than one command can be executed within each part of an **IF...THEN...ELSE** statement also, so:

