Upload
jonas-watts
View
212
Download
0
Embed Size (px)
Citation preview
1© 2002 John Urrutia. All rights reserved.
Qbasic Chapter 4
IF Statementsand
READ & DATA
2© 2002 John Urrutia. All rights reserved.
Boolean or Logical Expressions
Algebra created by George Boole
Always evaluates to a binary stateGenerally:
1 is TRUE0 is FALSE
3© 2002 John Urrutia. All rights reserved.
Relational ExpressionsSingle relational operator two operands
< Less than
> Greater than
= Equal to
<= Less than or equal to
>= Greater than or equal to
<> Not equal to
4© 2002 John Urrutia. All rights reserved.
One-way SelectionDown the primrose path or another IFy
situation.
IF condition THEN
statement(s)
END IF
5© 2002 John Urrutia. All rights reserved.
Two-way SelectionThere’s more than one-way to skin
a turkey.IF condition THEN
statement(s)
ELSE
statement(s)
END IF
6© 2002 John Urrutia. All rights reserved.
Nested IF StatementsIF condition THEN
IF condition THENstatement(s)
ELSEstatement(s)
END IFELSE
statement(s) END IF
7© 2002 John Urrutia. All rights reserved.
Multi-way SelectionIF condition THEN
statement(s)ELSEIF condition THEN
statement(s)ELSEIF condition THENstatement(s)
ELSEstatement(s)
END IF
8© 2002 John Urrutia. All rights reserved.
Logical OperatorsOp-1 Op-2 AND OR XOR
True True True True False
True False False True True
False True False True True
False False False False False
9© 2002 John Urrutia. All rights reserved.
Operator PrecedenceOrder of evaluation
^ Exponent
+ or - Unary (sign)
*, /, \, MOD Arithmetic
<, >, <=, Relational operators>=, <>, =
NOT, AND, Logical operatorsOR, XOR
10© 2002 John Urrutia. All rights reserved.
DATA & READ statementsDATA const, const, const, …
Provides internal storage
Accessed sequentially
READ var, var, var, …Populates variables from DATA
RESTORE labelResets the some or all the DATA