Quiz 7a

AMES 5

Quantitative Computer Skills

Quiz 7a, Feb. 16, 1999

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

1. Lists and tables are examples of arrays. Before using an array in a BASIC program, you must tell the computer its size with the DIM statement. An array can be declared only once in a DIM statement. The result of the program DIM day$(1 to 7) (new line) DATA sunday, monday, tuesday, wednesday, thursday, friday, saturday (new line) DO while more data (new line) LET i=i+1 (new line) READ day$(i) (new line) LOOP (new line) PRINT day$(3) (new line) END is

(a) an error message (b) sunday (c) tuesday (d) friday (e) a blank screen

2. The result of the program DIM day$(1 to 7) (new line) DATA sunday, monday, tuesday, wednesday, thursday, friday, saturday (new line) DO while more data (new line) LET i=i+1 (new line) READ day$(i) (new line) LOOP (new line) PRINT day$(6); lbound(day$); ubound(day$); size(day$) (new line) END is

(a) an error message (b) tuesday 1 7 7 (c) saturday 1 7 7 (d) friday 1 7 7 (e) saturday 0 7 8

3. The result of the program CALL number (x) (new line) LET y=3 (new line) LET z=2 (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=5 (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 smallest or most negative value of the index of an array is called the lower bound. The default value of the lower bound is one. The largest value of the index is called the upper bound, and its default value is the size of the array. If you want to use zero as the lower bound, you can start your program with option base 0. The result of the program OPTION BASE 0 (new line) DIM day$(0 to 7) (new line) DATA sunday, monday, tuesday, wednesday, thursday, friday, saturday, feb (new line) DO while more data (new line) READ day$(i) (new line) LET i=i+1 (new line) LOOP (new line) PRINT day$(3); size(day$); day$(7); lbound(day$); day$(0); ubound(day$) (new line) END is

(a) an error message (b) wednesday 8 feb 0 sunday 7 (c) tuesday 8 feb 0 sunday 7

(d) wednesday 7 feb 0 sunday 8 (e) wednesday 7 feb 0 sunday 8

5. The result of the program LIBRARY "graphlib" (new line) CALL polygon (.1,.2,.8,.9,4) (new line) END is

(a) an error message (b) a pentagon (c) a rectangle

(d) a triangle (e) a diamond in the upper left corner

6. Arrays with two or more indices are called multidimensional arrays. The result of the program DIM name$(1 to 3,1 to 3) (new line) LET name$(3,1)="Irma" (new line) PRINT name$(3,1) (new line) END is

(a) an error message (b) a blank screen (c) Irma (d) Mimi (e) $150

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

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

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

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

9. The result of the program DIM name$(1 to 3,1 to 3) (new line) LET name$(3,1)="Irma" (new line) PRINT name$(3,2) (new line) END is

(a) an error message (b) a blank screen (c) Irma (d) Mimi (e) $150

10. 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 Birthday!" (new line) END FUNCTION is

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

11. 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 4,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) 4 9 8 sum 95 (b) 4 9 8 sum 21 (c) 8 9 4 sum 21 (d) 9 4 8 sum 21 (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(3) (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(4,3,2,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 string$ = "Suez" (new line) CALL last (string$) (new line) PRINT string$ (new line) END (new line) SUB last (a$) (new line) LET a$=a$[len(a$):len(a$)] (new line) END SUB is

(a) an error message (b) S (c) z (d) u (e) e

15. The result of the program DIM list(1) (new line) MAT READ list(4) (new line) DATA 2,3,4,5 (new line) MAT PRINT list; (new line) PRINT list(3) (new line) END is

(a) error message (b) 2 3 4 5 4 (c) 2 3 4 5 (new line) (new line) 4 (d) a blank screen (e) 0

16. The result of the program PLOT LINES:.1,.9;.9,.9;.1,.1;.9,.1 (new line) END is

(a) an error message (b) two lines (c) three lines in the lower right hand side of the screen

(d) the sign of Zorro (e) three lines in the upper right hand side of the screen

17. The result of the program BOX CIRCLE .6,.8,.6,.9 (new line) SET COLOR "magenta/green" (new line) FLOOD .65,.75 (new line) END is

(a) a magenta ellipse on a green background (b) a magenta screen (c) an error message

(d) a green ellipse on a magenta background (e) a black screen