1 / 13

True BASIC Ch. 9 Practice Questions

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)

nura
Download Presentation

True BASIC Ch. 9 Practice Questions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. True BASIC Ch. 9 Practice Questions

  2. 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

  3. 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

  4. What are the 5 errors? REM REMcuz'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

  5. What are the 5 errors? REM REMcuz'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 • DIM command must come before array is used • PRINT should be INPUT prompt • names$ is a string array, must end with $ • Missing semi-colon to separate items • No multi-line PRINT’s, next line must start with PRINT

  6. 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

  7. 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

  8. 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

  9. What are the 4 errors? DIM mydata(3) FOR W = 1 TO 3 LETmydata(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

  10. 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

  11. 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

  12. 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

  13. 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

More Related