Qbasic Chapter 4 IF Statements and READ DATA
Qbasic Chapter 4 IF Statements and READ & DATA © 2002 John Urrutia. All rights reserved. 1
Boolean or Logical Expressions l. Algebra created by George Boole l. Always evaluates to a binary state èGenerally: w 1 is TRUE w 0 is FALSE © 2002 John Urrutia. All rights reserved. 2
Relational Expressions l. Single relational operator two operands è< Less than è> Greater than è= Equal to è<= Less than or equal to è>= Greater than or equal to è<> Not equal to © 2002 John Urrutia. All rights reserved. 3
One-way Selection l. Down the primrose path or another IFy situation. èIF condition THEN statement(s) END IF © 2002 John Urrutia. All rights reserved. 4
Two-way Selection l. There’s more than one-way to skin a turkey. èIF condition THEN statement(s) ELSE statement(s) END IF © 2002 John Urrutia. All rights reserved. 5
Nested IF Statements IF condition THEN statement(s) ELSE statement(s) END IF © 2002 John Urrutia. All rights reserved. 6
Multi-way Selection IF condition THEN statement(s) ELSEIF condition THEN statement(s) ELSE statement(s) END IF © 2002 John Urrutia. All rights reserved. 7
Logical Operators Op-1 Op-2 AND OR XOR True False True False True False False © 2002 John Urrutia. All rights reserved. 8
Operator Precedence l. Order of evaluation è^ Exponent è+ or - Unary (sign) è*, /, , MOD Arithmetic è<, >, <=, >=, <>, = Relational operators èNOT, AND, OR, XOR Logical operators © 2002 John Urrutia. All rights reserved. 9
DATA & READ statements l. DATA const, … èProvides internal storage èAccessed sequentially l. READ var, … èPopulates variables from DATA l. RESTORE label èResets the some or all the DATA © 2002 John Urrutia. All rights reserved. 10
- Slides: 10