AMES 5

Quantitative Computer Skills

Quiz 4a, January 26, 1999

(Closed book and notes, Choose one best answer, Write "Quiz 4a" on green scantron form)

1. True BASIC contains many types of useful functions in its set of standard functions, but not:

(a) arithmetic (b) trigonometric (c) double-line user (d) keyboard (e) conversion.

2. A standard function in BASIC is a named identifier to which one or more values are passed, in the form of constants, variables, or expressions. The function performs some calculation and returns a new string or numerical value. This returned value is assigned to:

(a) the data register (b) the value register (c) the function name (d) zero (e) null.

3. The output of the program LET name$ = "Nikita" (new line) PRINT len(name$) (new line) END is

(a) Nikita (b) 6 (c) 6$ (d) "6" (e) nikita.

4. The absolute value function is abs(x). It converts a negative numeric argument to a positive number. The result of the program PRINT abs(-1.2345) (new line) END is

(a) an error message (b) 1.2 (c) 1.2345 (d) +1.2345 (e) |1.2|.

5. The integer function int(x) modifies numerical variables like x, or constants. The program LET x$="6" (new line) PRINT int(x$) (new line) END where will result in

(a) an error message (b) 6 (c) "6" (d) |6| (e) a blank screen.

6. The function to round a number is round(x,n). It returns a value of x rounded to n digits after the decimal point. The result of the program PRINT round(3.123456,3) (new line) END is

(a) an error message (b) 3 (c) 3.12 (d) 3.123 (e) 3.1234.

7. The function to truncate a number or value is truncate(x,n). Both arguments x and n are always required. The output of the program PRINT truncate(3.1234,3) (new line) END is

(a) an error message (b) 3.12 (c) 3.123 (d) 3.1234 (e) 3.

8. Round(x,n) prints 123456. for x=123456.05 and n=2 because it is limited to eight significant figures in T-BASIC. The program PRINT using "######.##":123456.05 (new line) END gives

(a) an error message (b)123456.05 (c) 123456. (d) 123456.1 (e) 123456.__.

9. The functions fp(x) and ip(x) return the fractional part and integer parts of their argument. The program LET x=3.95 (new line) PRINT fp(x);ip(x) (new line) END produces

(a) an error message (b) 3.95 (c) .95 3 (d) 03.1 (e) 4.

10. The square root function sqr(x) returns a numerical value if x is not negative. The result of the program LET x=3 (new line) PRINT sqr(x) (new line) END is

(a) an error message (b) 9 (c) 1.73205 (d) ±1.73205 (e) 0.

11. The function mod(x,y) returns a numeric value equal to the remainder when x is divided by y. Division by zero is not allowed. The output of PRINT mod(127,25) (new line) END is

(a) an error message (b) 3 (c) 1 (d) 2 (e) 0.

12. The max(x,y) and min(x,y) functions compare two numeric arguments x and y and return a value equal to the larger or smaller argument, respectively. The value of max(12,-1) is

(a) -1 (b) 11 (c) 12 (d) 6 (e) 0.

13. The assignment or LET statement is used to assign a value to a variable. The program LET cost = 100 (new line) Let tax = 0.06 * cost (new line) PRINT Cost ; TAX (new line) END will result in:

(a) 6,100 (b) 6 100 (c) 100 6. (d) an error message (e) 100,6.

14. True BASIC is one of the first commercial versions of the Full BASIC programming language conforming to ANS BASIC standards. BASIC is one of the most widely used programming languages, and was first developed at Dartmouth College in:

(a) 1946 (b) 1996 (c) 1974 (d) 1964 (e) 1994.

15. The order of precedence for arithmetic operators is from left to right, first exponentiation, then multiplication and division, then addition and subtraction. Expressions within parentheses are always evaluated first. The value of LET X = 2*5 + (9/3)^(3 - 1) is:

(a) 1.e1 (b) 12 (c) 25 (d) 19 (e) 36.

16. If the string variable Trip$ has the value "travel in the country", the substring Trip$[5:9] has the value:

(a) el in (b) travel (c) untr (d) l int (e) vel in.

17. If the string variable is assigned a value by LET person$ = "Warren T. Wonka 486905555", where the numbers and spaces represent Warren's Zip Code, then you can extract his last name by the command LET Surname$ =

(a) person$[lastname$] (b) person$[12:16] (c) person$[11:15] (e) person${11:15}.

18. The response of LINE INPUT prompt "": name$ (new line) END (run) is a blank screen. If the user enters War,Peace the reponse is

(a) next item? (b) Too many input items. Excess ignored. (c) sets name$ to War,Peace.

19. The response of INPUT name$ (new line) END (run) is a question mark (?). If the user enters War,Peace the reponse is

(a) wrong! (b) Too few input items. Please add more. (c) sets name$ to War (d) War (e) Peace.

20. The program OPEN #1: name "test.file", create newold (new line) ERASE #1 (new line) PRINT #1: "the first line of test.file" (new line) END produces

(a) a file with one line (b) a blank file (c) #1 on the screen (d) an error message (e) disaster.