background image

Summary of Contents for 5110

Page 1: ..._ IBM 5110 BASIC Introduction _ IBM 5110 BASIC Introduction...

Page 2: ...01 Comments become the property of IBM Copyright International Business Machines Corporation 1978 o Preface This manual introduces the IBM 5110 Computer and its BASIC programming capability It is inte...

Page 3: ...4 Repositioning Files 92 Listing a Directory of Programs 44 A Review of What You ve Done 47 C c iii Contents CHAPTER 1 INTRODUCTION 1 CHAPTER 4 HOW TO WRITE A PROGRAM 49 About This Manual The LET Stat...

Page 4: ...47 BASIC System Commands 150 Editing Function 151 J APPENDIX B CUSTOMER SUPPORT FUNCTIONS 153 Ii tp CHAPTER 10 ARRAYS Defining an Array DIM Statement for One Dimensional Arrays DIM Statement for Two D...

Page 5: ...gure 1 The control panel consists of a series of switches which will be explained later Introduction c c Chapter 1 Introduction ABOUT THIS MANUAL This manual will show you how to operate the 5110 usin...

Page 6: ...rtridge 1 4 Arithmetic Operator Keys EXECUTE Key Shift Keys Figure 1 IBM 5110 Model 1 Computer 4 _f 2 What follows is a brief description of the keys How you use the keys will be described later For n...

Page 7: ...CfJ GJ GJ GJ G _ IJGJGJCDCDCDO JOJcoa DOC 0 0 0 Figure 3 Combined BASIC APl Keyboard Introduction 3 c c BBBGGBB MI 8 IEJEJ QOOJOJCD IJCDOG CJO CDGJGJGJGJCDGJQGJCDOO JOG CJ J GJ GJ GJ GJ GJ CJ GJ J OJ...

Page 8: ...calculator arrangement of numeric keys on the right of the keyboard can be used to enter numbers o 4 Alphameric Keys The alpha keys are similar to those on a standard typewriter except that there are...

Page 9: ...y Scroll Down Key HO EXECUTE Key Shift Key Space Bar Figure 4 Special Operating Keys Introduction 5 c c c Operating Keys The dark gray keys with the legend names CMD EXECUTE ATTN and HOLD and the dark...

Page 10: ...ch Setting L32 64 R32 64 DISPLAY REGISTERS NORMAL NORMAL BASIC APL combined machines only BASIC 1 r 6 BASIC Command Keywords The words listed above the top row of alphameric keys 1 0 are BASIC command...

Page 11: ...w seconds If the READY message still does not appear call your maintenance personnel Introduction 7 C c If your system has the BASIC APL switch it can execute either BASIC or APL language statements T...

Page 12: ...essed To process the data you just entered you must press the EXECUTE key Press EXECUTE now o f I 1 8 The LOAD 0 zero message indicates that the system has a clear work area The flashing underline _ b...

Page 13: ...o adjust the BRIGHTNESS control switch as you change from one background to the other Introduction 9 c c The display screen shows I 1 Notice that the instruction you entered 2 3 is on the left margin...

Page 14: ...I fl I 1 o I The value 200 is now on the input line and I I can be used as input UU PFi D o j I jf 10 Now watch the display as you set the L32 64 R32 switch to the L32 position With the switch in thi...

Page 15: ...splay screen From this point on only the line or lines being discussed will be shown Introduction 11 c Use the forward space key and move the cursor to the right of 200 Notice that the cursor the unde...

Page 16: ...SIC character mode Note All the entries in this manual are entered in standard BASIC character mode 12 Entering lowercase Alphabetic Characters Although only the standard BASIC alphabetic characters a...

Page 17: ...o the problem 22 12 but you press the following keys 88088 The display screen shows Introduction 13 c Correcting Keying Errors The system has a number of very useful functions that allow you to correc...

Page 18: ...want to do the problem 13 45 but you press the following keys CJOOCJ08 The display screen shows o 1 14 To correct this error the cursor must be moved back one position under the second 1 so that chara...

Page 19: ...ress The display screen looks like this Press the EXECUTE key to execute the problem Introduction 15 c c Press the backspace key to move the cursor flashing character back to the 2 Look at the labels...

Page 20: ...rsor position at the 3 hold down the CMD key while you press II once The display screen shows o i o 16 Insert a Character To insert a character position the cursor using the backspace key II or the fo...

Page 21: ...g You may now correct the error and then process the data again by pressing EXECUTE Introduction 17 C C C c To correct the keying error and execute the problem press the following keys There is one mo...

Page 22: ...o I Ii 18 o I Ii 18...

Page 23: ...Screen Shows 80G Subtract 8 from 5 JOG Multiply 5 times 8 JOG How Your System Handles Arithmetic 19 c C y Chapter 2 How Your System Handles Arithmetic The following examples show some common simple a...

Page 24: ...the dealer s total earnings if he made 20 on each car sold Possible Solutions Problem 1 3 1 0 o I I 20 Arithmetic You Press The Display Screen Shows Divide 5 by 8 5 to the power of 2 GJii8 4 to the po...

Page 25: ...value to a variable you can use the variable in a calculation How Your System Handles Arithmetic 21 L L C c Problem 2 U U 1 0 Problem 3 0 0 0 Problem 4 0 VARIABLES You can store data either direct in...

Page 26: ...ariable named A with a value of 12 The result of a calculation can also be assigned to a variable o 22 Examples To illustrate the use of variables enter the following ooo r t I 0 and After you press t...

Page 27: ...a value the system automatically assumes its value is zero 0 How Your System Handles Arithmetic 23 mOGJ8008 morn 0 _0_ til 0 1 I c I _ I c I C i c You can change the value of a variable the same way...

Page 28: ...ion has the highest priority The 8 result is then added to the 3 giving a final result of 3 8 o f _ 24 Performing Several Functions in the Same Expression In the preceding examples only one arithmetic...

Page 29: ...im result 3 formed and the result is displayed 90 Final result How Your System Handles Arithmetic 25 C C C Another example is 3 4 5 In this example the 3 and 4 are first added because they are enclose...

Page 30: ...result divide that result by 3 Figure 5 Examples of Arithmetic and BASIC Expressions o II 1 LJ rf 1 26 Although the numbers and operators in this expression are the same as those in the previous examp...

Page 31: ...s is included in the IBM 5110 BASIC Reference Manual SA21 930B How Your System Handles Arithmetic 27 c c As you can see the more complicated the arithmetic expression looks the more complicated the BA...

Page 32: ...81 or 457 25 Numbers in exponential format such as 6E7 meaning 6x107 or 5 4E 3 meaning 5 4x10 3 o o 28 You must use parentheses to separate consecutive operators as in the following examples Invalid V...

Page 33: ...er variable is 255 characters default length is 18 characters How Your System Handles Arithmetic 29 c c A Note About Names When you name numeric variables in BASIC they can be A single character of th...

Page 34: ...unction Notice that Calc Result is listed above the 8 key For example key the following and o I 1 i 30 Using Calculation Results When you are entering a series of expressions in which the result from...

Page 35: ...ses for this and following chapters are provided in Chapter 13 How Your System Handles Arithmetic 31 c c c The display screen shows Notice that the system inserted the result of A C into the second ex...

Page 36: ...32 01 tf o 32 01 tf o...

Page 37: ...J nf 1 1 PP I i 1 T C J i l I L T II C i C TC c 0 I T J P Entering Running and Storing a Program 33 Chapter 3 Entering Running and Storing a Program A program is your way to communicate with the syst...

Page 38: ...the program When you run the program the display screen shows PI IN I I I TJ i L P f I 1 C J Pi L o 34 Now read your entries on the display screen to see if you have entered the program correctly If y...

Page 39: ...splay the information you specified and compute the answer Entering Running and Storing a Program 35 c You will recognize the prompting message INITIAL PRINCIPAL as part of the second statement in the...

Page 40: ...you are finished however just enter 0 for principal and the program goes to statement 100 STOP o f 36 The statements in the sample program are described in the following paragraphs In addition Append...

Page 41: ...execution of a BASIC program and terminates operations C Entering Running and Storing a Program 37 Statement Meaning 50 PRINT INTEREST RATE This statement displays the NUMBER OF YEARS character strin...

Page 42: ...eady to Proceed 38 We ll Call This 1628 89 1 X X X Cursor Amount of Storage Position Available 1 _l The numbers preceding the statements are called statement numbers They are necessary so the system k...

Page 43: ...the 5110 Press the cartridge in until it is firmly seated Entering Running and Storing a Program 39 c c c USING TAPE OR DISKETTE STORAGE YOUR LIBRARY So far you have used only the 5110 active work are...

Page 44: ...40 Figure 7 II Sert 109 a Cartrid ge lot o the 5110 Nt odel1 r o V Ji a 40 Figure 7 II Sert 109 a Cartrid ge lot o the 5110 Nt odel1 r o V Ji a...

Page 45: ...nserted Figure 9 Inserting a Diskette in Diskette Drive 1 Entering Running and Storing a Program 41 c el Y c c If you are using a diskette 1 Be sure the diskette is initialized and contains no data re...

Page 46: ...ia If you want to mark additional files remember that you should begin with file number 4 o If jV C 42 Marking Your Media To prepare a tape or diskette with one file of any size or several files of th...

Page 47: ...use there is no program in storage Press ATIN to continue Entering Running and Storing a Program 43 c c c In the following examples if you are using diskette storage specify device address DBO diskett...

Page 48: ...kette only Data set starting location on diskette only Function keys defined in the file o 1 10 1 o 44 In order to run the program again it must first be loaded into storage from where it was stored o...

Page 49: ...istings see the IBM 5110 BASIC Reference Manual SA21 930B Entering Running and Storing a Program 45 C J c c A UTIL command for a typical tape directory is shown below UTIL 01R1 E80 The resulting outpu...

Page 50: ...al numbers RUN Executes a BASIC program UTIL Lists a directory of tape or diskette file information 46 The following commands have been discussed in this chapter AUTO MARK LOAD SAVE RD Automatically p...

Page 51: ...d programs from tape or diskette Clear the machine storage Entering Running and Storing a Program 47 c c c A REVIEW OF WHAT YOU VE DONE After reading this far and doing the exercises described you sho...

Page 52: ...o 0 1 0 48 o 0 1 0 48...

Page 53: ...g over 15 How much do you have to pay and how much does the insurance pay How to Write a Program 49 C J c Chapter 4 How to Write a Program In the following pages you are going to write more BASIC prog...

Page 54: ...execution of the program They are solely for information You can insert them anywhere in a program 50 What to Do 1 Find the total dentist bill call it 0 2 Subtract 15 to find the amount eligible for...

Page 55: ...ct part of the program Later program examples will explain this in detail How to Write a Program 51 C C c c To include a remark in a program you write a BASIC statement called REM It has a line number...

Page 56: ...e 20 of a program that tells the system to go to line number 60 would look like this 0020 GOTO 60 o 52 LISTING PROGRAM CONTENTS Because the dentbill program is currently in the system work area we can...

Page 57: ...n though you enter the system will display t when you list the statements How to Write a Program 53 c v c c The IF Statement An IF statement can test whether a variable is equal to greater than or les...

Page 58: ...j T C 1 I PD F 0020 2 0030 f 3 0050 If T 500 GOTO 0070 o0 0 0 I r o0 0 PF r NT U 1 0 o0 0 E r J P o 54 Some examples of IF statements are This IF Statement 0130 IF X 10 GOTO 40 0190 IF Y 21 GOTO 10 00...

Page 59: ...ow to have numbers printed in the exact format you want in a later chapter How to Write a Program 55 r 11 JI 1 c c c This program solves the problem in the following steps 1 It finds the total order l...

Page 60: ...e B After the PRINT statements the program comes to line 80 a STOP statement which ends the program 56 Program Example 2 You are moving You get estimates from two movers and want to know which mover w...

Page 61: ...9 0030 PRINT Y 0040 X 10 0050 Y 12 X 9 0060 PRINT Y and so on until X 20 How to Write a Program 57 c c c After you run the program the display screen shows Loops Here is a new problem You are a rug s...

Page 62: ...te a general statement that will keep increasing the value of X by 1 That statement is 0040 X X 1 f 58 This program uses a LET statement to increase the value of X However there is a better way You ca...

Page 63: ...0030 PRINT X Y 0040 X X 1 0050 IF X 20 GOTO 0070 0060 GOTO 0020 0070 STOP How to Write a Program 59 C c c c c Remember that while this statement looks peculiar in a mathematical sense it s perfectly v...

Page 64: ...ou write the statements that solve the problem and print the results 0020 Y 12 X 9 0030 PRINT X Y o 60 Looking at this program you should be able to see that lines 50 and 60 can be combined to make a...

Page 65: ...00 X X 2 To change X in steps of 2 0050 X X 10 To change X in steps of 10 How to Write a Program 61 C t c c Then you tell the system to go to the next value of X and repeat the loop 0040 NEXT X FOR an...

Page 66: ...s of its own it only defines the values for P 0020 FOR P 100 TO 1000 STEP 100 0070 NEXT P 1 1 1 j o 62 If you re using FOR and NEXT statements for the loop you add the word STEP and the size of the st...

Page 67: ...10 004 0 A 1 1 100 P 0050 PF INT PJl l 0060 NEXT I 0070 NEXT P lOBO STOP How to Write a Program 63 c c The P loop goes around the I loop P Loop OOPC o02 I F0 1 P 1 lOT 0 1 0 I 0 TE P 1 0 0 0030 FOR I...

Page 68: ...ver overlap like this FOR X r FOR Y NEXT X L NEXTY o eo I lj 1 I 63 I k B I 90 0 t O 70 eo O I 00 l 64 Run the program To see a portion of the program results press HOLD To continue execution press HO...

Page 69: ...0 10 16BO l f 1 t 51 Lt I 6 81 1 29 6 i 1 j S I 1 9 100 1000 1 0000 100000 How to Write a Program 65 c c Remember one loop must always be completely enclosed by the other Here is another example of lo...

Page 70: ...o I 66 o I 66...

Page 71: ...atement 0200 DATA 1 2 3 0210 DATA 4 5 6 0220 DATA 7 8 9 10 Other Ways to Put Values into Programs 67 c c Chapter 5 Other Ways to Put Values into Programs In all the programs we ve written we ve tried...

Page 72: ...es in the table To go back to the beginning of the table use the RESTORE statement 0100 RESTORE o o 68 Once the values are in the table you use the READ statement to assign them to variables Here s an...

Page 73: ...you re writing your program what values you want to assign Other Ways to Put Values into Programs 69 y j c c c Let s assume that you want to assign the values 1 2 and 3 to three variables A B and C in...

Page 74: ...ling scores you could use these statements 0045 PRINT ENTER THREE BOWLING SCORES 0050 INPUT X Y Z o 70 The INPUT statement allows a little more flexibility This statement names the variables that are...

Page 75: ...TA statements 0010 READ N H W 0020 DATA TOM JONES 6 1 184 Other Ways to Put Values into Programs 71 C C Then when the program is run instead of just a question mark appearing when it s time to enter y...

Page 76: ...you have a program where some values don t change some change occasionally and others change often 72 You could also use an INPUT statement 0010 INPUT N H W and then respond to the flashing question...

Page 77: ...e minutes T1 Amount of time over 3 minutes C Charge for the call Making Changes to Your Programs 73 c c c c Chapter 6 Making Changes to Your Programs It is very important that you be able to make chan...

Page 78: ...8 and press EXECUTE again To see what has been done with these statements enter the LIST command t 74 The program is o 1 1 I IF T 3 GIJTO OOll I 0020 PRINT CfiLL L E 3 THi IN OR E U I 3 hIN 1 0 C ENT...

Page 79: ...value Enter the following statement then press EXECUTE 6 DATA 21 Making Changes to Your Programs 75 _ f e l c c The display screen shows OOO 5 r tfD T 0006 D Ttl 3 o0 I 0 1FT 3 GOT 0 0 0l I o0 0 Pf I...

Page 80: ...PPINT LEt ClTH OF C I L 00 0 pr It T T oono PPli T CH iPGE FDr C I I 0f I P I f r c 0 1 00 TDP f 1 76 If you list the program now the display screen shows 0005 F EAD T 0006 Df T 1 0010 IF T 3 GOTD 00...

Page 81: ...T C H 1 PC E FDP C l LI 0 1 00 PFINT C o1 J 0 r I P o1 0 PPI r H Making Changes to Your Programs 77 c c c c _ __ _ The system has replaced line 5 and deleted line 6 When you want to delete a line simp...

Page 82: ...01 o 78 01 o 78...

Page 83: ...values of 7 and 825 here s what you see PFPCE ll C I J _OJ r 1 1 More About the PRINT Statement 79 C 1 r c c Chapter 7 More About the PRINT Statement We ve seen the PRINT statement used to display th...

Page 84: ...n the display screen shows Pl li j I L 1 0 I 0 i j I I Et 3E f I I I I IP NCE I l j q n 5 1 o i I t 80 If your system has an attached printer you can specify that the data be printed by entering PRINT...

Page 85: ...T X Xt2 instead of writing 0010 INPUT X 0020 Y Xt2 0030 PRINT X Y More About the PRINT Statement 81 C c You will be shown later how you can change the mileage allowance column to include trailing zero...

Page 86: ...82 o i o 82 o i o...

Page 87: ...ar in the displayed or printed data Setting Up Your Own Format PR INT USING and Image Statements 83 c c c Chapter 8 Setting Up Your Own Format PRINT USING and Image Statements A more flexible way to d...

Page 88: ...been previously dimensioned to the length of the image see Arrays Chapter 11 in a DIM statement o f 84 This is the way these two statements work together 0020 PRINT USING 30 G N The line number of 1 T...

Page 89: ...pply to the PRINT USING FLP statement Setting Up Your Own Format PRINT USING and Image Statements 85 I c o c An image statement always begins with a colon When you enter the signs as stand ins for var...

Page 90: ...f each week in the month Totals for everybody for each week Total for everybody for the month o _ l 86 Example of Printing There are three sales representatives in your department and you are responsi...

Page 91: ...de blank lines in the printed report Setting Up Your Own Format PRINT USING and Image Statements 87 c Supply sales representatives names Enter dates for the weeks Supply sales figures Compute monthly...

Page 92: ...O I t Ci lQ BOO OO I J OO 00 i 0 I 00 lOO OO I soo oo 100 00 3 5 TDTt l JO J 00 7 1 3 0 1DI t 2 5 o 88 i DI E t r IPPI E C 1 BBI i If your system has a printer you can run the program by entering a R...

Page 93: ...5110 BASIC Reference Manual SA21 9308 for a complete description of the OPEN statement Data Files 89 1 lr c c Chapter 9 Data Files A file is a collection of related data items that are stored together...

Page 94: ...0 you can create a tape or diskette file for example 0025 OPEN FL1 E80 2 OUT 0070 PUT FL1 T R A o o 90 Normally a file is deactivated or closed by the system after execution of your program However if...

Page 95: ...RINT T R A 0090 NEXT X These statements would print the 200 values for each T R and A Data Fi les 91 y This PUT statement instructs the system to put the values contained in the variables T R and A in...

Page 96: ...s you to build onto a file See RESET Statement in the IBM 5110 BASIC Reference Manual SA21 930S o J 92 REPOSITIONING FILES You may have an occasion to use an input file or an output file more than onc...

Page 97: ...e columns is Array B B l l B 1 2 B 1 3 B 2 1 8 2 2 B 23 B 3 1 8 3 2 B 33 B 4 1 8 4 2 B 4 3 Arrays 93 c c Chapter 10 Arrays With the BASIC language you can keep groups of similar data arithmetic or cha...

Page 98: ...49 4 82 5 60 3 02 6 64 2 87 7 75 2 04 8 81 1 89 9 71 2 74 10 59 2 90 11 46 1 85 12 37 2 35 o l I 0 94 To illustrate the use of one and two dimensional arrays suppose you are keeping weather statistic...

Page 99: ...an arithmetic one dimensional array A with 12 elements your DIM statement is 0010 DIM A 12 Arrays 95 c 0 The second example is really a modified combination of the three one dimensional arrays The fir...

Page 100: ...a length in a DIM statement the character variable has an assumed default length of 18 characters o 96 To define character array N with 20 elements your statement is 0010 DIM N 20 To define both toget...

Page 101: ...in each one dimensional array or the second row in W will be data for February and so on Arrays 97 c c c C j ELEMENTS OF ARRAYS Each individual item in an array is called an element of the array When...

Page 102: ...AD M 1 M 2 M 3 0030 DATA JANUARY FEBRUARY MARCH 0020 READ W 1 1 W 2 1 W 3 1 0030 DATA 1 2 3 o f _ 1 98 So far however there is no data in any of the arrays We have only defined the names and sizes Aft...

Page 103: ...thing is that the data must appear in the same order as if you were entering it row by row Arrays 99 C c c Again when you are using large amounts of data listing them all separately in a READ statemen...

Page 104: ...to assign values you can write a READ or INPUT statement such as 0020 MAT READ M 0030 MAT INPUT N o 100 INPUT Statements You can use INPUT statements to assign values from the keyboard to array elemen...

Page 105: ...arithmetic expression with this statement 0050 MAT T X or this statement 0060 MAT M X Y Z Arrays 101 c These statements tell the system to read in values for the entire array The letters MAT stand for...

Page 106: ...nce in organizing data Each element still has a value and can act as an independent variable o j Ci 102 The value you are assigning must be enclosed in parentheses so that the system knows it is not t...

Page 107: ...can be intermixed in a simple PRINT statement if the array reference is preceded by MAT Arrays 103 C C c c Printing Arrays Elements of arrays like ordinary variables can be used in any PRINT or PRINT...

Page 108: ...a single PRINT USING statement with a single image statement to print out 12 lines of data d 1 0 1 104 Putting One Dimensional Arrays Together in a Program Now we ll put the three one dimensional wea...

Page 109: ...O B0 FI P o0no ftl 0 NTH v i rEh P P I Ft LL FDR I r 4 0090 MAT PRINT FLP W ii 1 0 0 TDP Arrays 105 c C I C y After you enter the statements and run the program the display screen shows i lCJNTH iNUt...

Page 110: ...tures for January and divide by 2 add the temperatures fpr February and divide by 2 and so on o 1 I 106 The printed output is NONTH FD F 197LI 1 1 0 A 1 I i r 31 I 3 J q 8 r 60 j J 7 i c t Dl 1 9 I 1...

Page 111: ...constant a single variable or an arithmetic expression with this statement 0030 MAT C 2 A Arrays 107 I c c C I Addition and Subtraction with Arrays You can do all the addition in one step adding the e...

Page 112: ...y for the names of the months no matter how many years of data we have stored in other arrays o _ i 108 The multiplier a ways goes in parentheses so the system knows it is not another array and it mus...

Page 113: ...ix A When defining matrix a remember that it must have dimensions opposite to those of A Arrays 109 c Averaging Two Dimensional Arrays If the two sets of weather data are stored in two dimensional arr...

Page 114: ...when the determinant is zero you will cause an error that will stop your program from running o l o 110 The Identity Matrix You can make any square matrix a 2x2 matrix or a 12x12 matrix for example in...

Page 115: ...nd conversion constants in BASIC are discussed in this chapter More Things You Can Do With BASIC 111 I Chapter 11 More Things You Can Do With BASIC FINDING SQUARE ROOTS You can determine square roots...

Page 116: ...variable X and returns a value of 1 0 or 1 depending on whether X is negative zero or positive o l 112 SOME GENERAL SYSTEM FUNCTIONS Your system provides you with the following general functions in a...

Page 117: ...d 99 INT RND 1000 Produces a random integer between 0 and 999 More Things You Can Do With BASIC 113 c c You can also include expressions inside the parentheses for example INT Xt 2 Y 12 You might use...

Page 118: ...am statement would read 50 LET A PI R 2 You can use these constants anywhere in your programs o f o 114 ARITHMETIC CONSTANTS There are special constants in BASIC that are used to convert pounds inches...

Page 119: ...the elements of array A Gives the transpose matrix of array A More Things You Can Do With BASIC 115 c c CONVERSION FUNCTIONS BASIC has some built in ways to convert values from one measuring system to...

Page 120: ...hyperbolic sine of the real number X HTN X Gives the hyperbolic tangent of the real number X o f j 116 RECORD FILE FUNCTIONS BASIC provides three functions that allow you to inquire about record orie...

Page 121: ...r numeric scalars X1 scalars must be all character or numeric More Things You Can Do With BASIC 117 c c These functions deal in radians If your program measures angles in degrees instead of radians co...

Page 122: ...o f o 118 o f o 118...

Page 123: ...the totals do not match Yet you can t find anything wrong with your program If You Have Trouble 119 C c Chapter 12 If You Have Trouble This chapter discusses some common problems and errors that you...

Page 124: ...the integer results we would expect to get and not the odd decimal numbers that we had been getting 120 What Happened This problem occurred because the system sees numbers in a different way than we d...

Page 125: ...t skips to a GOTO or an IF followed by an IF that has the opposite condition If You Have Trouble 121 c c HOW CAN A VAGUE IDEA BECOME A PROGRAM First decide on your ultimate goal then simplify it Pick...

Page 126: ...122 o o 122 o o...

Page 127: ...his is because some chapters do not contain material for which exercises are relevant Exercises 123 C c Chapter 13 Exercises This chapter contains exercises for you to study and enter with your system...

Page 128: ...i l T THF I U 3 UI NC i VF H Ci F o0 5 0 1 5 I I j 1 3 1 I 3 0 1 o06 0 G S1 1 o0 0 PF It T o0D0 TOP 124 Exercises for Chapter 2 BASIC Arithmetic Problem 1 Find the length of side C in this right trian...

Page 129: ...TD r L D 01 20 PPINT l o l 3 I PF I NT tl t tl J 0140 PRINT B JBIBl 0150 PRINT CS C C Exercises 125 Problem 3 Here are the results of an election Candidate District 1 District 2 District 3 Adams Bill...

Page 130: ...I l 2 2 0060 PRINT B t o B 0070 C CHEAP CAR 0080 8 1 275 275 14 58 00 0 PRINT C C 0 1 00 3TOP o f f 126 Problem 4 You are shopping for an air conditioner You need one between 5000 and 6000 BTUs You wa...

Page 131: ...A 1 B 1 C 1 The computer will tell you why it doesn t work if you don t already know Exercises 127 C Problem 6 Equations of this form AX2 BX C 0 quadratic equations can be solved for the two values o...

Page 132: ...gallon The calculation in line 70 is based on half an ounce a day seven days a week for W weeks J r 128 Exercises for Chapter 4 How to Write a Program Problem 1 Dr Lemming sees an average of 60 patien...

Page 133: ...nd allowed four runs remember that 20 1 3 must be entered as 61 3 try your own numbers Exercises 129 c c c c Problem 2 Figure out the earned run average for a baseball pitcher who pitched 187 innings...

Page 134: ...20 lOOOO l17 0030 REM ADD ON THE PROFIT AND THE TAX OO O T S 05 S 2 5 OO O PF INT T 0060 STOP o t l 130 Problem 3 Find out how much sad Mr Harris has to buy to cover his 70x28 foot lawn If sad is 11 5...

Page 135: ...IVE IT THE tt E TIiviE 0120 0 1 30 PRINT THE SMITHS AND HOOPERS ARRIVE TOGETHER S fOP Exercises 131 1 C c Exercises for Branching Chapter 4 Problem 1 The Smiths and the Hoopers live next door to each...

Page 136: ...E CD T THI 1 rlj E o I 1 0 PI 1NT THE Y BDTH Htl VE 1 0 NTHI yeO ST F O l O PPINT f l 0 1 60 STOP o 132 Problem 2 You are looking for an apartment You find two one on your own and one through an agent...

Page 137: ...o1c 0 PPINT T1 0 1 0 P1 I NT E p P i TE RETU Pi if C Df T OlBO PRINT T3 0 1 9 0 f TD P Exercises 133 c c Problem 3 Mr and Mrs Richards are figuring out their income tax and they are trying to decide w...

Page 138: ...00 1 0 00 1 0 Pf INT I YOU CEED 1 000 1 JHFr 01 1 TR y TD t DII THE NUi lBEP OO iO PPINT N 0060 TOP 134 Exercises for Loops Chapter 4 Problem 1 In 1960 the population of Alpha City was 753 580 Its gro...

Page 139: ...P I I NT THE T T i I NUt l BE H 0 F CONIt I N I l I ON S I E 0 1 80 PRINT 0 1 90 TDP Exercises 135 c c Problem 3 Make a sales tax reference chart for yourself The sales tax in your state is 7 and you...

Page 140: ...P H Q D N P 0090 NEXT N 0 1 00 NEXT D 0 1 10 NEXT Q 0120 NEXT H 0130 PRINT FLP TOTAL WAYS C N P o 1 136 Because of the way the loops are nested in this program it is time consuming to execute A better...

Page 141: ...icant passed or not or whether the applicant should be allowed to take the test again Exercises 137 C Exercises for Chapter 5 Other Ways to Put Values into Programs Problem 1 Make a general program fo...

Page 142: ...we know that any scores surviving to line 100 are above 50 so we don t have to test them again o i 138 The Program 0010 PRINT ENTER NAME NUMBER OF WORDS NUMBER OF MISTAKES 0020 INPI JT N I hl M 0030...

Page 143: ...0290 PRINT FLP YOU DID NOT PASS MAKE AN APPOINTMENT TO SEE ME 0300 GOlD 1 0 0310 TOP Exercises 139 C C c c Exercise for Chapter 8 Setting Up Your Own Format PRINT USING and Image Statements You are a...

Page 144: ...hapter 5 Also column D is exactly the same as column A except each element is bumped by one place o 140 Exercise for Chapter 10 Arrays Here is the 1972 Internal Revenue schedule for single taxpayers W...

Page 145: ...h column corresponds to which array The Program llj onn U I I i j 0 0 n 1 q Lf j 0 c n Exercises 141 c c The columns of the schedule are labeled to show which column corresponds to which array The Pro...

Page 146: ...o 6 0 GOlD 00 o 0 PHI NT FLP THE 0 I TEI i 1 I N 1 NT DF D I 0 I THE HE I N I I NVEF E o B0 TOP o o 142 Here are two square matrices 14 10 13 2 o 27 7J 1 8 6 4 5 3 24 2 5 38 9 Write a program that pri...

Page 147: ...OT0 16 0 O l iO PF INl THE B li lCH Pf N In CI O 3Elx TO THE PEQUIF ED IZE 0 1 60 TDP Exercises 143 c C v Exercises for Chapter 11 More Things You Can Do with BASIC Problem 1 Make a chart of the value...

Page 148: ...the result Then we applied the INT function to extract just the integer part of the number l 1 __ 1 144 Problem 3 Write a program where the system thinks of a number and you have to guess the number T...

Page 149: ...IS A GOOD LANGUAGE TO EXPERIMENT WITH THE MORE YOU EXPERIMENT THE MORE YOU LEARN CI c Exercises 145 REMEMBER BASIC IS A GOOD LANGUAGE TO EXPERIMENT WITH THE MORE YOU EXPERIMENT THE MORE YOU LEARN CI...

Page 150: ...o o 146 o o 146...

Page 151: ...n a file created for access by individual record or printed output BASIC Statements and Commands 147 1 C C Appendix A BASIC Statements and Commands A complete list of the statements and commands in th...

Page 152: ...expressions or constants in a format defined in an image statement or variable or FORM statement 148 MAT GET Assign values from a stream oriented file to variables 0 GOSUB Transfers program control to...

Page 153: ...ING Adds a record to the end of a record oriented file C y C I y c BASIC Statements and Commands 149 MAT PUT Writes the values of specified variables into a tape or diskette stream oriented file MAT R...

Page 154: ...lts Renumbers the statements in storage Rewinds the tape cartridge Executes a BASIC program o ___ J BASIC SYSTEM COMMANDS ALERT AUTO eSKIP GO LINK LIST LOAD MARK MERGE PRoe RD RENUM REWIND RUN 150 Ale...

Page 155: ...atements from storage Allows editing of key groups where X 0 to 9 BASIC Statements and Commands 151 SAVE SKIP UTIL EDITING FUNCTION DEL KEYx c c Saves the BASIC program or data on tape or diskette Unc...

Page 156: ...o l I 152 o l I 152...

Page 157: ...ptical feature Compress diskette files to make unused space available Customer Support Functions 153 c c Appendix B Customer Support Functions The following customer support functions are available fo...

Page 158: ...o J f c i 154 o J f c i 154...

Page 159: ...nds AUTO 38 46 GO 35 LOAD 44 46 MARK 42 46 RD 35 46 RUN 35 46 SAVE 43 46 UTIL 44 46 Index Index 155 c c c c A I DN identity matrix 115 about BASIC 1 about the 5110 1 about this manual ABS x absolute v...

Page 160: ...nctions 112 GET statement 89 getting started 6 GO command 35 GOTO statement 37 52 59 119 o 1 llh _J commands BASIC system 150 conversion constants 114 conversion functions 115 copy display function 34...

Page 161: ...t the PRINT statement 79 more things you can do with BASIC 111 multiplication 6 19 107 109 Index 157 C _ C c c HCS x hyperbolic cosine 116 HO LD key 5 33 60 64 how can a vague idea become a program 12...

Page 162: ...5 square roots 111 114 standard BASIC character mode 12 starting 6 statement keywords 6 33 147 o o naming arrays 93 95 natural log e 114 negative operators 24 27 nested loops 62 NEXT statement 61 100...

Page 163: ...ults 30 working with elements of arrays 97 102 write a program how to 49 5110 description Index 159 c c c c statement numbering automatic 38 77 statements 147 status line 8 steps 61 stop flashing scre...

Page 164: ...160 o 11 1 _ i 160 o 11 1 _ i...

Page 165: ...d you include your name and address Page Number Comment Name Address I OJ l OJ a Q c o I 0 en l cO w o 0 6 o READER OMENT FORM Please use this form only to identify publication errors or request chang...

Page 166: ...A International Fold FIRST CLASS PERM IT NO 40 ARMONK N Y Fold I I O c o CD ro a 5 c C I J cO 0 6 J SA21 9306 0 Fold BUSINESS REPLY MAIL NO POSTAGE STAMP NECESSARY IF MAILED IN THE UNITED STATES Fold...

Page 167: ...ur name and address Page Number Comment Name Address 1 I c I l en a a Co c n o l CD 1J 0 en l cO w o en 6 READER OMENT FORM Please use this form only to identify publication errors or request changes...

Page 168: ...CLASS PERMIT NO 40 ARMONK N Y Fold I I O c 0 l cc r 1 _ l I I I I irtf 1 11 1 I 1 a 5 C C to 0 6 7 SA21 9306 O Fold BUSINESS REPLY MAIL NO POSTAGE STAMP NECESSARY IF MAILED IN THE UNITED STATES Fold...

Page 169: ...o o o o o o o _ _ _ _ _ _ _ _ _ _ _ _ _ _ o o o o o o o _ _ _ _ _ _ _ _ _ _ _ _ _ _...

Page 170: ...6 0 I I I I 1 1 c o o _ CJ u g Ecn2 al _al I i OJ s 0 OJ 3 a c o I CD a I 1 c en en cO f w 0 0 ji 6 International Business Machines Corporation General Systems Division 4111 Northside Parkway N W P O...

Reviews: