Trailing-Edge
-
PDP-10 Archives
-
decus_20tap1_198111
-
decus/20-0024/tutr05.bas
There are 2 other files named tutr05.bas in the archive. Click here to see a list.
00001REM TUT5
00100PRINT"I'M BACK AGAIN. GLAD YOU'RE STILL HERE. LET'S SEE........"
00110PRINT
00120PRINT"THE PROGRAM AS IT NOW STANDS SAYS:"
00130PRINT
00140PRINT" 11 READ X,Y,Z"
00150PRINT" 12 DATA 3,4,12,8,15,11"
00155PRINT" 20 LET R=SQR(X^2+Y^2+Z^2)"
00160PRINT" 30 PRINT ''THE RADIUS VECTOR EQUALS'';R"
00170PRINT" 35 GO TO 9"
00180PRINT" 40 END"
00190PRINT
00200PRINT"LET'S USE THE 'GO TO' STATEMENT ALREADY IN THE PROGRAM, BUT"
00210PRINT"CHANGE IT TO EITHER 'GO TO 11' OR ELSE TO 'GO TO 12'. ONLY"
00220PRINT"ONE OF THESE IS CORRECT. DO YOU THINK IT IS '11' OR '12'";
00230INPUTV
00240PRINT
00250IFV=11THEN 290
00260IFV=12THEN 290
00270PRINT"YOUR ANSWER HAS TO BE EITHER 11 OR 12. WHICH IS IT";
00280GOTO 230
00290PRINT"'11' IS CORRECT, BECAUSE IT IS 'READ' WHICH WE WANT DONE TWICE."
00300PRINT"'DATA' IS NOT A SEQUENTIAL INSTRUCTION - JUST INFORMATION FOR"
00310PRINT"THE MACHINE. INCIDENTALLY, THE 'DATA' STATEMENT MAY BE PLACED"
00320PRINT"ANYWHERE IN THE PROGRAM PRECEDING 'END'. TO ILLUSTRATE THIS,"
00330PRINT"LET'S MOVE IT FROM LINE 12 TO LINE 38. THE PROGRAM WILL NOW BE:"
00340PRINT
00350PRINT" 11 READ X,Y,Z"
00360PRINT" 20 LET R=SQR(X^2+Y^2+Z^2)"
00370PRINT" 30 PRINT ''THE RADIUS VECTOR EQUALS'';R"
00380PRINT" 35 GO TO 11"
00390PRINT" 38 DATA 3,4,12,8,15,11"
00400PRINT" 40 END"
00410PRINT
00420PRINT"WHEN 'RUN' IS TYPED BY THE USER, THE COMPUTER WILL RESPOND:"
00430PRINT
00440PRINT" THE RADIUS VECTOR EQUALS 13"
00450PRINT" THE RADIUS VECTOR EQUALS 20.2485"
00460PRINT" OUT OF DATA IN 11"
00465PRINT
00470PRINT"THIS IS FINE, BUT THE COMPUTER DOESN'T SAY WHAT SET OF VALUES WE"
00480PRINT"USED FOR EACH ONE. SO WE CAN ADD A SECOND PRINT STATEMENT:"
00490PRINT
00500PRINT" 25 PRINT ''X, Y, AND Z VALUES ARE, RESPECTIVELY:''; X, Y, Z"
00510PRINT
00520PRINT"THE LINE NUMBER SHOULD BE BETWEEN 20 AND 30 SO IT WILL PRECEDE"
00530PRINT"THE 'PRINT' ON LINE 30. SO NOW OUR PROGRAM MIGHT WELL BE:"
00540PRINT
00550PRINT" 11 READ X,Y,Z"
00560PRINT" 20 LET R=SQR(X^2+Y^2+Z^2)"
00570PRINT" 25 PRINT ''X, Y, AND Z VALUES ARE, RESPECTIVELY:''; X, Y, Z"
00575PRINT" 30 PRINT ''THE RADIUS VECTOR EQUALS'';R"
00580PRINT" 35 GO TO 11"
00590PRINT" 38 DATA 3,4,12,8,15,11"
00600PRINT" 40 END"
00610PRINT
00620PRINT"AND THE COMPUTER RESPONSE IS:"
00625PRINT
00630PRINT" X, Y, AND Z VALUES ARE, RESPECTIVELY: 3, 4, 12"
00640PRINT" THE RADIUS VECTOR EQUALS 13"
00650PRINT" X, Y, AND Z VALUES ARE, RESPECTIVELY: 8, 15, 11"
00660PRINT" THE RADIUS VECTOR EQUALS 20.2485"
00662PRINT" OUT OF DATA IN 11"
00665PRINT
00670PRINT"THIS PROVIDES THE NECESSARY INFORMATION. IF THE QUANTITY OF"
00680PRINT"DATA EXCEEDS THE AVAILABLE LINE SPACE IN THE 'DATA' STATEMENT,"
00690PRINT"ADDITIONAL 'DATA' STATEMENTS CAN BE USED, SO LONG AS THEY ARE"
00700PRINT"NUMBERED SUCH THAT THE DATA ARE SEQUENCED PROPERLY."
00701PRINT
00710PRINT"NOTICE THAT THE INPUT VALUES IN EACH SET MUST HAVE DIFFERENT"
00720PRINT"NAMES (I.E., X, Y, AND Z). WE COULD CALL THEM ALL BY THE SAME"
00730PRINT"NAME BY USING SUBSCRIPTS. THE COMPUTER DOES THIS BY PARENTHESES."
00740PRINT"SO INSTEAD OF X, Y, AND Z, WE COULD USE, SAY, W(1), W(2), AND"
00750PRINT"W(3) - THEN CHANGE PROGRAM STATEMENTS ACCORDINGLY. THE PRESENT"
00760PRINT"SEQUENCE OF STATEMENTS IS:11,20,25,30,35,38, AND 40. WHICH IS"
00770PRINT"THE FIRST ONE WE MUST MAKE A CHANGE IN? (NATURALLY, LINE NUMBERS"
00780PRINT"WOULD NOT CHANGE.) THE LINE NUMBER OF THE STATEMENT WOULD BE..";
00800INPUTU
00810PRINT
00820IFU=11THEN 850
00830PRINT"LOOK AT THE PROGRAM MORE CAREFULLY. TRY AGAIN. WHICH";
00840GOTO 800
00850PRINT"RIGHT. HOW MANY STATEMENTS WOULD NOT HAVE TO BE CHANGED";
00860INPUTS
00870PRINT
00880IFS=4THEN970
00890PRINT"LOOK REAL CLOSE. AGAIN......";
00900 GO TO 860
00970PRINT"THAT'S THE IDEA. BUT WITH SUBSCRIPTS, THE COMPUTER MUST BE"
00980PRINT"'WARNED' TO RESERVE SUFFICIENT MEMORY SPACE FOR THE VALUES. "
00990PRINT"THE TERM FOR THIS IS THE WORD 'DIMENSION'. WHICH OF THE BELOW"
01000PRINT"INSTRUCTIONS DO YOU THINK MIGHT 'RESERVE STORAGE'?"
01010PRINT
01020PRINT" KEY (TYPE '1' FOR THIS CHOICE)"
01030PRINT" TAPE (TYPE '2' FOR THIS CHOICE)"
01040PRINT" DIM W(3) (TYPE '3' FOR THIS CHOICE)"
01045PRINT
01050PRINT"YOUR CHOICE IS........";
01060INPUTQ
01070PRINT
01080IFQ=3THEN 1150
01090IFQ<3THEN 1120
01100PRINT"NO SUCH CHOICE. AGAIN......";
01110GOTO 1060
01120PRINT"NO, BUT WE'LL TAKE UP THAT INSTRUCTION IN A FUTURE LESSON."
01130PRINT"TAKE ANOTHER GUESS......";
01140GOTO 1060
01150PRINT"RIGHT. 'DIM' STANDS FOR 'DIMENSION', 'W' IS THE NAME, AND"
01160PRINT"'(3)' IS THE NUMBER OF LOCATIONS NEEDED. (YOU MAY RESERVE MORE"
01170PRINT"THAN YOU EXPECT TO USE, IF YOU WISH). IF WE USE SUBSCRIPTS, IT"
01180PRINT"IS NOT ADVISABLE TO USE THE 'GO TO' STATEMENT FOR REPEATED SETS"
01190PRINT"OF DATA. THEREFORE, LET US ASSUME THAT WE WILL HAVE ONLY ONE"
01200PRINT"SET OF VALUES FOR OUR THREE W'S (WE'LL TAKE A CLOSER LOOK AT"
01210PRINT"THE USE OF SUBSCRIPTS IN A FUTURE LESSON). SO WE CAN ELIMINATE"
01220PRINT"THE 'GO TO' INSTRUCTION, AND THAT LEAVES US A PROGRAM WITH THE"
01230PRINT"'DIM' STATEMENT BUT NO 'GO TO' STATEMENT. HERE'S A POSSIBILITY:"
01240PRINT
01250PRINT" 8 DIM W(3)"
01260PRINT" 11 READ W(1), W(2), W(3)"
01270PRINT" 20 LET R=SQR(W(1)^2+W(2)^2+W(3)^2)"
01290PRINT" 25 PRINT ''W(1), W(2), AND W(3) ARE:''; W(1), W(2), W(3)"
01300PRINT" 30 PRINT ''THE RADIUS VECTOR EQUALS'';R"
01310PRINT" 38 DATA 3,4,12"
01320PRINT" 40 END"
01330PRINT
01340PRINT"NOTE THAT 'DIM' SHOULD BE PUT FIRST. THIS IS SO IT WILL 'SET UP'"
01350PRINT"THE COMPUTER'S MEMORY FOR THE PROBLEM."
01360PRINT
01370PRINT"WELL, YOU'VE COMPLETED ANOTHER LESSON. BE SURE TO TRY YOUR"
01380PRINT"PROBLEMS ON THE COMPUTER EVERY CHANCE YOU GET. SEE YOU SOON."
01390PRINT"CALL 'TUTR06' WHEN YOU ARE READY FOR YOUR NEXT LESSON."
01400 END