200 likes | 592 Views
Qbasic. Input, Calculations and Functions. The INPUT statement. INPUT variable-list INPUT “ prompt ” ; or , variable-list prompt – any valid string ; – Question mark generated , – No Question mark generated variable-list – mix and match separate with commas.
E N D
Qbasic Input, Calculations and Functions
The INPUT statement • INPUT variable-listINPUT “prompt ” ; or , variable-list • prompt – any valid string • ; – Question mark generated • , – No Question mark generated • variable-list – mix and match separate with commas
DATA & READ statements • DATA const, const, const, … • Provides internal storage • Accessed sequentially • READ var, var, var, … • Populates variables from DATA • RESTORE label • Resets the some or all the DATA
Calculations • Order of operations (precedence) • ^ (Power) • +, - (Unary) • *, /, \, MOD, +, - (Arithmetic) • <, <=, >, >=, <>, = (Relational) • Boolean operators • NOT, AND, OR, XOR, EQV, IMP
Boolean Operators • NOT – negation (bit-wise complement) • AND – logical addition (conjunction) • OR – logical subtraction (disjunction) • XOR – exclusive “or” • EQV – logical equivalence • IMP – logical implication
NOT Boolean Truth Tables NOT True False False True
AND Boolean Truth Tables AND True True True False True False False True False False False False
OR Boolean Truth Tables OR True True True True True False False True True False False False
XOR Boolean Truth Tables XOR True True False True True False False True True False False False
Arithmetic Operators • * – Multiplication • / – Division • \ – Integer Division • MOD – Modula (remainder) • + – Addition • - – Subtraction
Functions • A function is a set of instructions that perform a specific task. • FunctionName (argument1, …) • Built-in & User defined X$ = UCASE$(X$)
Built-in Functions • Mathematic • SQR, EXP, LOG • Trigonometric • SIN, COS, TAN • String • RIGHT$, LEFT$, MID$
Built-in Functions • Conversions • MKI$ - CVI, MKD$ - CVD • CHR$ - ASC • System • DATE$ - TIME$