Title: Beginning to Program Variables, Etc'
1Beginning to ProgramVariables, Etc.
2Variables
Names we give to storage locations in RAM.
3Variables
Names we give to storage locations in RAM.
Length
4Variables
Names we give to storage locations in RAM.
Length Width
5Variables
Names we give to storage locations in RAM.
Length Width Area
6Variable names
- Must begin with a letter
- Should be descriptive and meaningful
- May not contain spaces or special characters
7Valid or Invalid??
8Assignment Statements
- Use LET to give a variable a value.
LET variable ___
9LET Statement Examples
- LET Age 17
- LET Age 6.5
- LET Cost 4.99
- LET TaxRate .07125
- LET NegNumber -4
No or commas!
10Use LET Statements for
- INPUT to store a value in RAM and give its
location a name so it can be used later. - PROCESSING calculations
11Computer Calculations
12Computer Calculations
13Computer Calculations
14Computer Calculations
15Write these expressions in Basic
16Write these expressions in Basic
- 4x 5y 3 4 x 5 y 3
- 6c 6 c
- 7r 5 7 r 5
- a2b2 a 2 b 2
- a a b b
17Evaluate these expressions
- 1 2 3
- 5 (4 3) / 2
- 1 (2 3) 2 - 1
18LET Statement Examples
- LET Total a b
- LET Half Num / 2
- LET GrossPay Hours Rate
Variable on left formula on right
19Hey! Not all data is numeric.
20What about words and names?
21Think of some data that is not numeric
22Non-numeric data are called strings.
String variables end with
23LET Statement Examples
Variable ends with string in
- LET Word Hi
- LET Name Sue
- Let Title War and Peace
24What else do we need? We can...
- Use LET for Input
- Use LET for Processing
- Use PRINT for Output
25(No Transcript)