Quiz 5b

AMES 5

Quantitative Computer Skills

Quiz 5b, Feb. 4, 1999

(Closed book and notes, Choose one best answer, Use green scantron form)

1. A common method of debugging computer programs is to put temporary print statements at key points in the program. What is the result of the following program? LET x=exp(1) (new line) PRINT "x should be e at this point: it is...";x ! TEMP (new line) END

(a) an error message (b) 2.303 (c) 2.718 (d) 0 (e) x should be e at this point: it is... 2.71828

2. The result of the program PLOT TEXT, AT .1,.1:".1,.1" (new line) END is

(a) an error message (b) .1,.1 in the upper left hand corner of the screen (c) .1,.1 in the lower left hand corner of the screen (d) an empty screen (e) a beep

3. The result of the program BOX LINES .1,.4,.1,.4 (new line) END

(a) an error message (b) a square in the lower left hand corner of the screen (c) a rectangle in the lower left hand corner of the screen (d) a sequence of beeps (e) a blank screen

4. The result of the program BOX circle .1,.4,.1,.4 (new line) END

(a) an error message (b) a circle in the lower left hand corner of the screen (c) an ellipse in the lower left hand corner of the screen (d) a sequence of beeps (e) a blank screen

5. The result of the program BOX ellipse .1,.4,.1,.4 (new line) END

(a) an error message (b) a sequence of beeps (c) an ellipse in the lower left hand corner of the screen (d) a circle in the lower left hand corner of the screen (e) a blank screen

6. One should avoid using numerical equalities as logical tests in computer programs

(a) true (b) false (c) maybe (d) unpredictable (e) possibly.

7. The function pos(target$,pattern$,position) returns a value giving the location of the first character of the pattern string pattern$ in the target string target$. The optional third argument position specifies the position in target$ where the search starts (the default is at the left). The result of the program LET string$ = "abcdeabcdeabcdeabcdeabcdeabcde" (new line) PRINT pos(string$,"c",14) (new line) END is

(a) an error message (b) 13 (c) 14 (d) 18 (e) 15

8. The result of the program LET string$ = "abcdeabcdeabcdeabcdeabcdeabcde" (new line) PRINT posr(string$,"c",14) (new line) END is

(a) an error message (b) 13 (c) 14 (d) 18 (e) 15

9. The sequence for trapping errors in True Basic is WHEN EXCEPTION IN (new line) protected block (new line) USE (new line) exception handler block (new line) END WHEN. If no run-time error occurs in the protected block, the program skips to

(a) an error message (b) the first statement after END WHEN (c) the exception handler block

(d) extext$ (e) extype

10. The result of the program BOX ELLIPSE .1,.4,.1,.4 (new line) FLOOD 0,0 (new line) END is

(a) an error message (b) a sequence of beeps (c) a black ellipse in the lower left hand corner of a white screen (d) a white ellipse in the lower left hand corner of a black screen (e) a circle

 

11. The output of the program LET when$="mm-dd-yy" (new line) LET year$=when$[posr(when$,"-")+1:100] (new line) PRINT year$ ! TEMP (new line) END is

(a) an error message (b) yy (c) -d (d) dd (e) dd-yy

12. The result of the program BOX ELLIPSE .1,.4,.14,.56 (new line) FLOOD .2,.2 (new line) END

(a) an error message (b) a sequence of beeps (c) a black circle in the lower left hand corner of a white screen (d) a white circle in the lower left hand corner of a black screen (e) an ellipse

13. The result of the program PLOT LINES:.2,.8;.3,.7 (new line) END is

(a) an error message (b) two lines (c) a line in the lower right hand side of the screen (d) a line in the upper left hand corner of the screen (e) a line in the upper right hand side of the screen

14. The result of the program PLOT LINES:.7,.8;.8,.7 (new line) END is

(a) an error message (b) two lines (c) a line in the lower right hand side of the screen (d) a line in the upper left hand corner of the screen (e) a line in the upper right hand side of the screen

15. The result of the program PLOT LINES:PLOT LINES:.7,.8;.8,.7;.2,.8 (new line) END (new line) (new line) END is

(a) an error message (b) two lines (c) a line in the lower right hand side of the screen (d) a line in the upper left hand corner of the screen (e) a line in the upper right hand side of the screen

16. The result of the program PLOT LINES:PLOT LINES:.7,.8;.8,.7;.2 (new line) END (new line) (new line) END is

(a) an error message (b) two lines (c) a line in the lower right hand side of the screen (d) a line in the upper left hand corner of the screen (e) a line in the upper right hand side of the screen

17. The result of the program LET x=6 (new line) WHEN error in (new line) LET y = log(x) (new line) PRINT "x is ...";x;"log(x) is ...";y (new line) USE (new line) PRINT extype;extext$ (new line) END WHEN (new line) END

(a) an error message (b) x is ... 6 log(x) is ... 1.79176 (c) 1.79176 6 3004 (d) 3004 LOG of number <= 0. (e) a blank screen

18. The result of the program LET x=-6 (new line) WHEN error in (new line) LET y = log(x) (new line) PRINT "x is ...";x;"log(x) is ...";y (new line) USE (new line) PRINT extype;extext$ (new line) END WHEN (new line) END

(a) an error message (b) x is ... 6 log(x) is ... 1.79176 (c) 1.79176 6 3004 (d) 3004 LOG of number <= 0. (e) a blank screen

19. The result of the program FOR i = 1 to 2 (new line) LET x=log(i) (new line) PRINT i;x; (new line) NEXT i (new line) END

(a) 1 0 2 .30103 (b) 1 0 2 1 (c) an error message (d) a beep (e) 1 0 2 .693147

20. The result of the program FOR i = 1 to 2 (new line) LET x=log2(i) (new line) PRINT i;x; (new line) NEXT i (new line) END

(a) 1 0 2 .30103 (b) 1 0 2 1 (c) an error message (d) a beep (e) 1 0 2 .693147