# True BASIC Ch. 9 Practice Questions. What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT What is the new Y INPUT.

## Presentation on theme: "True BASIC Ch. 9 Practice Questions. What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT What is the new Y INPUT."— Presentation transcript:

True BASIC Ch. 9 Practice Questions

What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT What is the new Y INPUT 2Y NEXT X DATA 23, 72, 91

What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT "What is the new Y" INPUT Y NEXT X DATA 23, 72, 91, 12 END 1) Missing double quotes around string 2) Variable names cannot start with numbers 3) Insufficient Data – 4 items needed 4) Missing END statement

What are the 5 errors? REM REM cuz'z INPUT PROMPT "What's your name?" : names\$(1) DIM names\$(3) PRINT "Cousin's name is " : names\$(2) PRINT names(2);"’s other cousin's name is"; INPUT names\$(3) PRINT names\$(1);" & ";names\$(3)" are "; " siblings or 2nd cousins" END

What are the 5 errors? REM REM cuz'z DIM names\$(3) INPUT PROMPT "What's your name?" : names\$(1) INPUT PROMPT "Cousin's name is " : names\$(2) PRINT names\$(2);"’s other cousin's name is"; INPUT names\$(3) PRINT names\$(1);" & ";names\$(3);" are "; PRINT " siblings or 2nd cousins" END 1)DIM command must come before array is used 2)PRINT should be INPUT prompt 3)names\$ is a string array, must end with \$ 4)Missing semi-colon to separate items 5)No multi-line PRINT’s, next line must start with PRINT

What is the output? DIM num(2), word\$(2) READ word\$(1), num(1) DATA "eleven" READ word\$(2), num(2) DATA 11, "thirteen", 13 IF num(1)>num(2) THEN PRINT word\$(1);" bigger" SELECT CASE word\$(2) CASE IS = "thirteen" PRINT "good" CASE "thirteen" PRINT "great" CASE ELSE PRINT "fantastic" END SELECT END

What is the output? DIM num(2), word\$(2) READ word\$(1), num(1) DATA "eleven" READ word\$(2), num(2) DATA 11, "thirteen", 13 IF num(1)>num(2) THEN PRINT word\$(1);" bigger" SELECT CASE word\$(2) CASE IS = "thirteen" PRINT "good" CASE "thirteen" PRINT "great" CASE ELSE PRINT "fantastic" END SELECT END OUTPUT good

What are the 4 errors? DIM mydata(3) FOR W = 1 TO 3 mydata(W) = 2 LOOP DATA 1,2,3 LET mydata(W) = 3 INPUT mydata(1) PRINT "done" REM yay! END

What are the 4 errors? DIM mydata(3) FOR W = 1 TO 3 LET mydata(W) = 2 NEXT W DATA 1,2,3 LET mydata(W-1) = 3 INPUT mydata(1) PRINT "done" ! yay! END 1) Missing LET in value assignment 2) FOR loop ends with NEXT (variable) 3) W is 4 after loop, which exceeds array bounds. Fix by using W-1 or making array dimension 4 (DIM mydata(4) at top) 4) REM is for a whole line comment. Use ! for an inline comment

What are the 4 errors? DIM arr\$(0 TO 3) READ arr\$(0 TO 3) SELECT CASE arr\$(1) CASE 2 INPUT X CASE ELSE PRINT arr(1) END CASE DATA "1","2", "3", "4" END

What are the 4 errors? DIM arr\$(0 TO 3) READ arr\$(0),arr\$(1),arr\$(2),arr\$(3) SELECT CASE arr\$(1) CASE "2" INPUT X CASE ELSE PRINT arr\$(1) END SELECT DATA "1","2", "3", "4" END 1) Cannot READ a range (TO for array appears only in DIM) 2) Missing double quotes around string 3) arr\$ is a string array, so it needs a \$ 4) SELECT CASE ends with END SELECT

What is the output? DIM nums(1000) LET X = 1 DO LET nums(X) = INT(10 / X^2) LET X = X + 1 LOOP UNTIL nums(X-1) = 0 PRINT "loop iterations = ";(X - 1) FOR Y = 1 TO X-1 PRINT nums(Y) NEXT Y END

What is the output? DIM nums(1000) LET X = 1 DO LET nums(X) = INT(10 / X^2) LET X = X + 1 LOOP UNTIL nums(X-1) = 0 PRINT "loop iterations = ";(X - 1) FOR Y = 1 TO X-1 PRINT nums(Y) NEXT Y END OUTPUT loop iterations = 4 10 2 1 0

Download ppt "True BASIC Ch. 9 Practice Questions. What are the 4 errors? DIM arr(4) FOR X = 1 TO 4 READ arr(X) LET arr(X) = arr(X) * X PRINT What is the new Y INPUT."

Similar presentations