BASIC3.WPS
BASIC LANGUAGE PROGRAMMING
USING VARIABLES IN SIMPLE PROGRAMS
When we design programs in basic we must often assign values to variables. The BASIC programming language allows for 2 basic types of variables.
Numeric variables represent numbers only. EXAMPLES:
AGE = 19
TEMPERATURE = 98.6
YEAR = 1995
String variables represent information other than just numbers. The variable name must
end in a $ sign and information must be put in quotes. EXAMPLES:
ADDRESS$ = "10 KING ST."
PHONE$ = "555-1234"
NAMES$= "JANE SMITH"
NOTE*** Almost Any name can be used for a variable name except:
1) BASIC COMMANDS
2) NAMES CANNOT BEGIN WITH A NUMBER
3) NAMES CANNOT HAVE SYMBOLS IN THEM (EX:@,#,?)
Complete the following exercise and write beside each variable if the
variable is a string or numeric variable and if the variable is valid or invalid.
If the variable is invalid, write why it is invalid on the VALID/INVALID line.
If the variable is invalid, write the reason it is invalid to the right
of the VALID/INVALID space.
VARIABLE TYPE VALID/INVALID
1) END _____________ __________________
2) G$ _____________ __________________
3) 4GATE _____________ __________________
4) QUESTION _____________ __________________
5) TAXES*$ _____________ __________________
6) AGE$ _____________ __________________
7) REM _____________ __________________
8) YEARS OLD _____________ __________________
9) 4STAFF _____________ __________________
10) STAFF4 _____________ __________________
11) 4STAFF$ _____________ __________________
12) G.S.T. _____________ __________________
13) G.S.T.$ _____________ __________________
14) DIR _____________ __________________
15) PAINT$ _____________ __________________
16) BYE$ _____________ __________________
17) G*O*$ _____________ __________________
18) SCHOOL _____________ __________________
19) SCHOOL$ _____________ __________________
20) SCHOOL15 _____________ __________________
21) LIST _____________ __________________
22) BILL% _____________ __________________
23) 1ST _____________ __________________
24) ^^^HOUSE _____________ __________________
25) LET _____________ __________________
26) LET$ _____________ __________________
27) CLEAR _____________ __________________
28) 98SKIDOO _____________ __________________
29) BY _____________ __________________
Copyright -Barry Boyle (bboyle@kawartha.net)