AMES 5

Quantitative Computer Skills

Quiz 4b, January 28, 1999

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

1. In trigonometry, the sine of the angle x is the opposite side of a right triangle divided by the hypotenuse, where x is in radians. How many degrees are enclosed by one radian?

(a) 2p (b) p (c) 360/2pi (d) 30 (e) 360.

2. The default unit for trigonometric functions is the radian. The result of the program OPTION ANGLE radians (new line) LET y = sin(pi/2) (new line) PRINT y (new line) END is

(a) 0 (b) p (c) an error message (d) 1 (e) a blank screen.

3. T-BASIC can also do calculations in degrees. The result of the program OPTION ANGLE degrees (new line) LET y = sin(deg(pi/2)) (new line) PRINT y (new line) END is

(a) 0 (b) p (c) an error message (d) 1 (e) a blank screen.

4. T-BASIC has three logarithmic functions; log(x), log2(x), and log10(x). Note that B = logA(A^B). The result of the program LET x = 100 (new line) PRINT using "###.#": log(x),log2(x),log10(x) (new line) END is

(a) 0 (b) an error message (c) 6.6 2.0 4.6 (d) 2.0 6.6 4.6 (e) 4.6 6.6 2.0

5. The random number function is rnd and it returns a random number less than 1 and greater than or equal to 0. If the modifying statement randomize is executed prior to the use of the rnd function, the function returns a different random number of sequence of random numbers each time the program is run. The result of the program RANDOMIZE (new line) PRINT using "#.#": rnd,rnd (new line) END is 1.0 .8. The next time the program runs it will produce

(a) 1.0 .8 (b) .8 1.0 (c) an error message (d) unpredictable (e) -1 -.8.

6. The result of the program PRINT using "#.#": rnd,rnd (new line) END is 1.0 .8. The next time the program runs it will produce

(a) 1.0 .8 (b) .8 1.0 (c) an error message (d) unpredictable (e) -1 -.8.

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",7) (new line) END is

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

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

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

9. The result of the program LET name$=ucase$(john paul jones) (new line) PRINT name$ (new line) END is

(a) an error message (b) JOHN PAUL JONES (c) john paul jones (d) 1 (e) John Paul Jones

 

10. The ord(a$) function returns a numeric value equal to the ASCII code of the single character string a$. The chr$(x) function returns a single-character string value. The result of the program PRINT ord("A"); (new line) PRINT chr$(66); (new line) PRINT chr$(90); (new line) PRINT ord("a") (new line) END is 65 BZ 97. What is the result of the program PRINT ord("b"); (new line) PRINT chr$(67); (new line) PRINT chr$(89); (new line) PRINT ord("B") (new line) END ?

(a) an error message (b) 98 CY 66 (c) 99 DW 68 (d) 1 (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 (new line) END is

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

12. 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

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 str$(x) function returns a string whose characters are the same as those in the number x. The result of the program PRINT str$(1.23E4) (new line) END is

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

15. The tab(x) print function allows format control in a print statement, and can only be used in a print statement. It moves the cursor to column x before the next expression is displayed. The result of the program PRINT "a";tab(4);"bc";tab(8);bcd (new line) END is

(a) a bc bcd (b) A BC BCD (c) an error message (d) abcbcd (e) a bc 0

16. The logical expression END DATA for the program in 15. is (a) true (b) false

17. The logical expression MORE DATA for the program in 15. is (a) true (b) false

18. To return to the source screen for the following program DO until key input (new line) LOOP (new line) END you must

(a) click the mouse twice (b) hit any key (c) click the mouse, hit a key (d) hit any key twice (e) 0

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 B?

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

20. Both ANS BASIC and T-BASIC allow the user to define a single-line function using the def function statement. The result of the program DEF vol (l,w,h)=l*w*h (new line) LET l=2 (new line) LET w=3*l (new line) LET h=4 (new line) PRINT vol (l,w,h) (new line) END is

(a) 24 (b) 48 (c) 64 (d) 67 (e) 63