Code | Explanation |
| |
While getKy=0 | Continues looping until you press a key |
For(X,0,100,5 | Uses every 5th number from 0 to 100; the 5 is optional |
IS>(X,50:Disp "Greater than 50. | If X<50, it adds 1 to X each loop until it
can display the message |
DS>(X,50:Disp "Less than 50. | If X<50, it subtracts 1 from X each loop until
it can display the message |
End | Ends the For...End statement and its looping |
End | Ends the While...End statement and its looping |
DelVar(X | Deletes the variable X |
The
Code | Explanation |
| |
Float | Lets values have up to 12 decimal points |
Normal | Make values appear in normal notation |
ClLCD | Clears the screen |
Disp "1. A2","2. B2","3. C2 | Displays 3 lines of options using 1 command, very efficient. |
0→A | Stores A as 0, so there's no error when you press a key. |
While A≠92 or A≠93 or A≠94 or A≠45 | loops unless you press 1, 2, 3, or CLEAR |
getKy→A | Any key press is stored in A |
If A==92 or A==93:Goto C | Goes to the label C if you press 1 or 2. |
If A==94:Goto A | Goes to the label A if you press 3. |
If A==45:Goto D | Goes to the label D if you press CLEAR. |
End | Unless you pressed a key, it loops and checks again |
Lbl C | Starts the C label |
ClLCD | Clears the screen |
If A==92 | Simply, if you pressed 1 |
Then | The the program will |
"B2:"→D | Stores the string "B:" as D |
Else | But if you pressed 2 instead |
"A2:"→D | Stores the string "A:" as D |
End | Ends this checking and storing |
Input "C2:",C | Asks you for C2 and stores it as C |
Input D,B | Asks you for A2 (if 2 was pressed) or B2 (if 1 was pressed) and stores it as B |
Disp C-B,√(C-B | Displays A2 or B2, and either A or B |
Pause | Pauses so you can copy the answer |
Goto D | Goes to the label D to quit |
Lbl A | Starts the A label |
ClLCD | Clears the screen |
Input "A2:",A | Asks you for A2 and stores it as A |
Input "B2:",B | Asks you for B2 and stores it as B |
Disp A+B,√(A+B | Displays C2 and C |
Pause | Pauses so you can copy the answer |
Lbl D | Starts the label D |
ClLCD | Clears the screen |
DelVar(A | Deletes the variable A |
DelVar(B | Deletes the variable B |
DelVar(C | Deletes the variable C |
DelVar(D | Deletes the variable D |
Always read though the 'Explanations' to see what's going on. Once you read and understand this Lesson you can call yourself a programmer when applying what you've learned. There's nothing new in the Pythagorean Theorem program except the use of logic and the use of a few arithmatic functions. Make sure you know why it works before continuing. I can't explain this any further, because then you wouldn't learn how to solve the 'Why and How' of logical operations yourself.