Read operators in a line of BASIC
THE BASIC LANGUAGE
The same equals sign can assign or compare. Read the whole line. In coins = 3 it sets a value. In IF coins = 3 THEN it asks a question.
| Arithmetic | + adds, − subtracts (type the plain minus key), * multiplies, / divides, and MOD gives the remainder. For 17 MOD 6 the answer is 5. |
|---|---|
| Assignment | Use =, +=, -=, *= and /= to update a variable. Use CONST if later reassignment should produce a validation error. |
| Comparison | Use = and <> for equal and unequal. Use <, <=, > and >= for ordered comparisons. |
| Logic | AND needs both tests to succeed. OR needs either one. NOT reverses a test. ANDALSO and ORELSE are short-circuit aliases. |
| Join text | Use & between pieces of text. Parentheses make the order clear when you mix arithmetic with concatenation. |
Predict the result#
DIM coins = 3
DIM has_pass = FALSE
DIM admitted = coins >= 2 OR has_pass
PRINT "Admitted: " & admittedThis is a fragment for Run. The left half of OR is true because three is at least two. Admitted is therefore true. Set coins to 1 and has_pass to FALSE to reach the other result.
