Quiz 6b

AMES 5

Quantitative Computer Skills

Quiz 6b, Feb. 11, 1999

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

1. Local variables provide isolation between the main program and procedures, and between individual procedures.

(a) true (b) false (c) whatever (d) not for pictures (e) only for pictures

2. The result of the program CALL number (x) (new line) LET y=1 (new line) PRINT x;y;z (new line) LET y=3 (new line) LET z=2 (new line) LET x=5 (new line) END (new line) SUB number(z) (new line) LET z=2 (new line) LET x=7 (new line) LET y=6 (new line) LET z=4 (new line) END SUB is

(a) 0 1 4 (b) 0 0 0 (c) 5 3 2 (d) 4 1 0 (e) 7 6 4

3. The result of the program CALL number (x) (new line) LET y=6 (new line) LET z=4 (new line) PRINT x;y;z (new line) LET y=1 (new line) LET x=5 (new line) END (new line) SUB number(x) (new line) LET z=2 (new line) LET x=7 (new line) LET y=1 (new line) LET z=0 (new line) END SUB is

(a) 0 1 4 (b) 0 0 0 (c) 5 3 2 (d) 4 1 0 (e) 7 6 4

4. The parameters in a function heading statement are variables, separated from one another by commas, and are of type string or numeric. DECLARE FUNCTION volume (new line) READ a,b,c (new line) DATA 2,4,6 (new line) PRINT volume(a,b,c) (new line) END (new line) FUNCTION volume (l,w,h) (new line) LET volume=l*w*h (new line) END FUNCTION

(a) an error message (b) 48 (c) 24 (d) 0 (e) 8

5. Libraries of procedures can be constructed, saved on disk, and subsequently incorporated into new True BASIC programs. The result of the program LIBRARY "graphlib" (new line) CALL polygon (.1,.2,.8,.9,5) (new line) END is

(a) an error message (b) a pentagon (c) a square (d) a triangle (e) a triangle in the upper left corner

6. A module is a library of external functions and subroutines with some special properties. Like any other library file, it is included in a program by naming it in a LIBRARY statement. The first statement in a module named grades is

(a) special (b) external (c) begin grades (d) module grades (e) end module

7. The result of the program LET string\$ = "abcdeabcdeabcde" (new line) PRINT cpos(string\$,"dcb",10) (new line) END is

(a) an error message (b) 12 (c) 10 (d) 11 (e) 9

8. The result of the program LET string\$ = "abcdeabcdeabcde" (new line) PRINT cposr(string\$,"dcb",10) (new line) END is

(a) an error message (b) 12 (c) 10 (d) 11 (e) 9

9. The result of the program DECLARE FUNCTION greeting\$ (new line) PRINT greeting\$(2) (new line) END (new line) EXTERNAL function greeting\$ (x) (new line) IF x=1 then (new line) SET COLOR "blue" (new line) LET greeting\$="Happy Birthday!" (new line) ELSEIF x=2 then (new line) SET COLOR "red" (new line) LET greeting\$="Happy Valentine's Day!" (new line) ELSE (new line) SET COLOR "brown" (new line) PRINT "invalid choice" (new line) SOUND 400,.5 (new line) END IF (new line) END FUNCTION

(a) an error message (b) Happy Birthday (c) Happy Valentine's Day! (d) invalid choice (e) null

10. An external function unit performs some calculation and returns a string or numeric value that is assigned to the function name. The result of the program DECLARE FUNCTION greeting\$ (new line) PRINT greeting\$ (new line) END (new line) EXTERNAL function greeting\$ (new line) LET greeting\$="Happy Valentine's Day!" (new line) END FUNCTION is

(a) an error message (b) Happy Birthday (c) Happy Valentine's Day! (d) invalid choice (e) null

11. Information is passed to external functions by means of "one-way", or "value" parameters that are local variables in the function heading statement. The result of the program DECLARE FUNCTION sum (new line) DIM num(1 to 3) (new line) FOR i=1 to 3 (new line) READ num(i) (new line) PRINT num(i); (new line) NEXT i (new line) PRINT "sum";sum(num()) (new line) DATA 5,9,8 (new line) END (new line) EXTERNAL function sum(list()) (new line) FOR k=1 to 3 (new line) LET x=x+list(k) (new line) NEXT k (new line) LET sum=x (new line) END FUNCTION is

(a) 5 9 8 sum 95 (b) 5 9 8 sum 22 (c) 8 9 5 sum 22 (d) 9 5 8 sum 22 (e) 0 0 0 sum 0.

12. The program DIM list(4) (new line) FOR i=1 to 4 (new line) READ list(i) (new line) PRINT list(i); (new line) NEXT i (new line) PRINT list(2) (new line) DATA 2,3,4,5 (new line) END shows how to use one dimensional arrays such as list(). The result is

(a) 4 3 2 3 5 (b) 2 3 4 5 2 (c) 2 3 4 5 3 (d) 2 3 4 5 5 (e) 2 3 4 5 4

13. The program CALL volume(1,3,3,vol) (new line) PRINT vol (new line) END (new line) SUB volume(l,w,h,prod) (new line) LET prod=l*w*h (new line) END SUB has the result

(a) 0 (b) 24 (c) an error message (d) a blank screen (e) 9

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 result of the program PLOT LINES:.7,.8;.8,.7 (new line) END is

(a) Expected "," (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:.7,.1;.8,.4 (new line) END is

(a) Expected "," (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 BOX CIRCLE .6,.7,.7,.8 (new line) SET COLOR "blue/yellow" (new line) FLOOD .65,.75 (new line) END is

(a) a yellow ellipse on a blue background (b) a blue ellipse on a yellow background (c) an error message (d) an ellipse on a blue screen (e) an ellipse on a yellow screen

18. The result of the program BOX CIRCLE .6,.7,.7,.8 (new line) SET COLOR "blue/yellow" (new line) FLOOD .65,.75 (new line) FLOOD .65,.85 (new line) END is

(a) a yellow ellipse on a blue background (b) a blue ellipse on a yellow background (c) an error message (d) an ellipse on a blue screen (e) an ellipse on a yellow screen