Sharp OZ-707 Operation Manual - Page 33
Example, Complex, Programming
![]() |
UPC - 074000012141
View all Sharp OZ-707 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 33 highlights
Enter this program: 10: INPUT "WORD?";A$ 20: B=LEN(A$) 30: PRINT "THE WORD (";A$;") HAS" 40: PRINT B;" LETTERS" 50: END The second new element in this program is the use of the END statement to signal the completion of a program. END tells the Card that the program is completed. It is always good programming practice to use an END statement. As your programs get more complex you may wish to review them before you begin execution. To look at your program, use the LIST command. LIST, which can only be used in the PRO mode, displays programs beginning with the lowest line number. Try listing this program: LIS T IENTER I H3:I;AN$PUT "WORD?" 20:B=LEN (A$) 30:PRRDIN(T";A"T$H;E") WHO 40:PARSI"NT B;" LET TERS" Use the [K] and ~ keys to move through your program until you have reviewed the entire program. After checking your program, change to the RUN mode and run it IeeCE I RUN IENTER I HE L P ~:UN l·JORD?HELP _ RUN ~JORD?HELP THE WORD (HELP) HAS >4 LETTERS 54 This is the end of your program. Of course you may begin it again by entering RUN. However, this program would be a bit more entertaining if it presented more than one opportunity for input. We will now modify the program so it will keep running without entering RUN after each answer. Return to the PRO mode and use the CZSJ or ~ key (or LIST) to reach line 50, or enter: LIS T 5 0 IENTER I I 5e'END You may enter 50 to delete the entire line or use the [EJ key to position the cursor over the E in END. Change line 50 so that it reads: 50: GOTO 10 Now RUN the modified program. The GOTO statement causes the program to loop (keep repeating the same operation). Since you put no limit on the loop it will keep going forever (an "infinite" loop). To stop this program press the 00 key. When you have stopped a program using the 00 key, you can restart it using the CONT command. CONT stands for CONTinue. With the CONT command the program will restart on the line that was being executed when the 00 key was pressed. Example 4 - More Complex Programming The following program computes N factorial (NI). The program begins with 1 and computes NI up to the limit that you enter. Enter this program: 100: F = 1: WAIT 118 110: INPUT "LlMIT?";L 120: FOR N = 1 TO L 130: F = F*N 140: PRINT N,F 150: NEXT N 160: END 55
![](/manual_guide/products/sharp-oz707-operation-manual-7aa0508/33.png)