AMES 5

Quantitative Computer Skills

Quiz 5a, Feb. 2, 1999

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

1. A large fraction of the time spent developing a computer program is devoted to finding and eliminating errors. The most common source of error is

(a) too much planning (b) Y2K (c) too little planning (d) the textbook (e) Ira.

2. The first method to be used in debugging a faulty computer program is

(a) run do trace (b) read the program pretending you are the computer (c) insert temporary print statements (d) strike the monitor sharply on its left side with your hand (e) ask the TA to fix it.

3. When program execution has been stopped by a break command, one can

(a) correct program mistakes (b) change variable values (c) (d) 1 (e) not continue.

4. The result of the program DO until z = .1 (new line) LET z = z+.01 (new line) PRINT z; (new line) LOOP (new line) END

(a) a row of 10 numbers (b) a column of 10 numbers (c) a row of 11 numbers (d) a column of 11 numbers (e) a very long loop

5. The result of the program DO until z >= .1 (new line) LET z = z+.01 (new line) PRINT z; (new line) LOOP (new line) END

(a) a row of 10 numbers (b) a column of 10 numbers (c) a row of 11 numbers (d) a column of 11 numbers (e) a very long loop

6. One should avoid using numerical inequalities 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$ = "abcdeabcdeabcde" (new line) PRINT pos(string$,"e",11) (new line) END is

(a) an error message (b) 0 (c) 10 (d) 5 (e) 15

8. The result of the program LET string$ = "abcdeabcdeabcde" (new line) PRINT posr(string$,"e",11) (new line) END is

(a) an error message (b) 0 (c) 10 (d) 5 (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 a 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 LET ratio=1.4 (new line) SET WINDOW -(50*ratio),(50*ratio),-50,50 (new line) DRAW circle(10,0,0) (new line) END (new line) PICTURE circle(r,x,y) (new line) BOX CIRCLE x-r,x+r,y-r,y+r (new line) END PICTURE is

(a) a square (b) a triangle (c) a circle (d) an error message (e) a blank screen

11. The output of the double block IF-THEN-ELSE structured program LET a=3 (new line) IF a=4 THEN (new line) PRINT "helium" (new line) ELSE (new line) PRINT "hydrogen" (new line) END IF is

(a) hydrogen (b) helium (c) an error message (d) disaster (e) a blank screen.

12. The result of the program LET x=6 (new line) WHEN exception in (new line) LET z=sqr(x) (new line) PRINT x;z (new line) USE (new line) PRINT extype;extext$ (new line) END WHEN (new line) END is

(a) exception (b) 3005 SQR of negative number. (c) an error message (d) 6 2.44949 (e) disaster

13. The val(a$) function returns a numeric value equal to the number represented by the digit characters in a$. The result of the program PRINT val(-123e3) (new line) END is

(a) -123000 (b) -1.230E4 (c) an error message (d) "-123,000" (e) disaster

14. The result of the program LET x=-6 (new line) WHEN exception in (new line) LET z=sqr(x) (new line) PRINT x;z (new line) USE (new line) PRINT extype;extext$ (new line) END WHEN (new line) END is

(a) exception (b) 3005 SQR of negative number. (c) an error message (d) 6 2.44949 (e) disaster

15. The val(a$) function returns a numeric value equal to the number represented by the digit characters in a$. The result of the program PRINT val("-123e3") (new line) END is

(a) -123000 (b) -1.230E4 (c) an error message (d) "-123,000" (e) "-123000"

16. The test phrase Key Input is a logical test or logical function, returning a value of true if the user has pressed a key since the last time the program read input from the keyboard. The program DO until key input (new line) SOUND 100,.5 (new line) LOOP (new line) GET KEY dummy (new line) END

(a) is stopped by hitting any key (b) can't be stopped (c) gives an error message (d) draws a circle (e) prints the ascii value of the character of the key pressed

17. The program DO until key input (new line) SOUND 100,.5 (new line) LOOP (new line) END

(a) is started by hitting any key (b) can't be stopped (c) gives an error message (d) draws a circle (e) prints the character of the key pressed in the source program

18. The value of log10(1000) is 3. The value of log(10) is 2.3. What is exp(1)?

(a) 3 (b) 10 (c) 1000 (d) 2.718 (e) 2.3

19. The get key x command waits for a key and assigns a numeric value to x corresponding to the ASCII value of the character produced by the key. The result of the program GET KEY x (new line) PRINT x (new line) END is 65 when the key A is hit. What if the key were C?

(a) 63 (b) 64 (c) 65 (d) 66 (e) 67

20. The result of the program PRINT repeat$("$",5) (new line) END is

(a) an error message (b) ***** (c) $$$$$ (d) 3005 (e) a blank screen