Quiz 6a

AMES 5

Quantitative Computer Skills

Quiz 6a, Feb. 9, 1999

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

1. Modern computer languages allow a program to be designed as a series of independent program units or procedures. Examples of program units do not include

(a) the main program (b) external functions (c) external subroutines (d) external pictures (e) Emily.

2. Arguments and parameters allow information to be passed to external procedures and, in the case of external subroutines, to return information to the original program. Arguments are part of the calling statement, parameters are part of the procedure heading.

(a) true (b) false(c) it depends (d) not for pictures (e) never on Sunday.

3. Local variables provide isolation between the main program and procedures, and between individual procedures. The result of the program CALL number (x) (new line) PRINT x;y (new line) END (new line) SUB number (y) (new line) LET y=7 (new line) LET x=4 (new line) END SUB is

(a) 0 0 (b) 7 4 (c) an error message (d) 7 0 (e) 0 7

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

(a) an error message (b) 4 0 (c) 7 0 (d) 0 4 (e) 0 0

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,3) (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. The first statement in a LIBRARY of procedures is

(a) silence (b) external (c) library (d) greetings (e) shoes and shirts required

7. The function cpos(target$,pattern$,position) returns a value giving the first location of any 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 cpos(string$,"dcb",5) (new line) END is

(a) an error message (b) 8 (c) 10 (d) 9 (e) 7

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

(a) an error message (b) 4 (c) 3 (d) 2 (e) 7

9. The main program (or one of the procedures) can make use of one or more other procedures as it carries out its task, and it is then identified as the calling program unit. Any procedure can be called from any other procedure or from the main program.

(a) true (b) false (c) only on PCs (d) except for functions (e) only on Macs.

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 Valentine's Day!" (c) Happy Valentine's Day! (d) 0 (e) 666

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 22 (b) 5 9 8 sum 95 (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 3 (new line) READ list(i) (new line) PRINT list(i); (new line) NEXT i (new line) PRINT list(4) (new line) DATA 2,3,4 (new line) END shows how to use one dimensional arrays such as list(). The result is

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

13. The program CALL volume(2,3,4,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;.2,.8 (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,.8;.8,.7;.2 (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 "magenta/yellow" (new line) FLOOD .65,.75 (new line) END is

(a) a yellow ellipse on a magenta background (b) a magenta ellipse on a yellow background (c) an error message (d) a magenta screen (e) a circular box

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

(a) a yellow ellipse on a magenta background (b) a magenta ellipse on a yellow background (c) an error message (d) a magenta screen (e) a circular box

19. Arguments are part of the calling statement, parameters are part of the procedure heading

(a) true (b) false (c) whatever (d) not according to the constitution (e) What was the question?

20. Parameters are never variables

(a) true (b) false (c) whatever (d) not according to the constitution (e) What was the question?