# QBASIC - PDF

Document Sample

```					                                                     QBASIC

Knowledge of the QBASIC programming language: commands and syntax, reading code, recognition of errors and
debugging coding of a verbal problem. (3 s.h.)                                          COS-110-TE

This is a three-hour examination in which you must answer 100 multiple-choice questions (worth 1 point each).
A passing score is 60 out of 100 points.

Here are the topics covered and their approximate importance on the test:

I.     KNOWLEDGE OF QBASIC COMMANDS AND SYNTAX                          (50%)

Program format, documentation (REM), input, output, assignment, numeric and string variables, control
transfer, conditional control transfer, arithmetic and relational operators, built-in arithmetic functions,
formatting of output (TAB, PRINT USING), interactive input, arrays, subroutines, built-in string functions,
definite and indefinite loops, error traps, counters, accumulators, sorting

II.    ABILITY TO READ CODE, DETERMINE INPUT, OUTPUT, AND PROGRAM FLOW (40%)

III.   RECOGNITION OF ERRORS AND DEBUGGING                     (5%)

IV.    ABILITY TO RECOGNIZE THE CORRECTLY CODED SOLUTION TO A VERBAL                                (5%)
PROBLEM

Most college-level texts in this subject will provide appropriate preparation for this exam. Therefore, we do not
recommend specific ones.

Examination Sections:

Sections One & Two         54 questions - knowledge of QBASIC commands
Section Three              12 questions - code reading and determining output
Section Four                8 questions - error recognition and debugging
Section Five                8 questions - code reading and determining output
Section Six                 4 questions - ability to recognize correctly coded solution to a verbal problem
Section Seven              14 questions - ability to read a complete program and answer questions
regarding input, output, and program flow

SAMPLE QUESTIONS

Section One Format

In this section you will see a line of code followed by four descriptions of what will happen when the line of code is
executed. Choose the answer that best describes the result when the given line of code is executed.

1.     LET X = Y - 2

a.   The variables X and Y both receive the value 2.
b.   The variable X receives the value of Y squared.
c.   The variable X receives the value of Y minus 2.
d.   An error message is displayed due to a type mismatch.
2.    IF Z = 10 THEN GOSUB ONE

a.   Control is passed to the line labeled “ONE” if Z equals 10.
b.   Control is passed to the line labeled “ONE” if Z does not equal 10.
c.   Control is passed to the line labeled “ONE” if Z occurs in line 10.
d.   If Z equals 10, its value is changed to 1.

3.    PRINT X, Y\$, Z\$

a.   The expression X, Y\$, Z\$ is printed.
b.   The variable X receives the value of Y\$ + Z\$.
c.   One numerical value and two string values are printed.
d.   An error message is displayed, because 3 variables cannot be printed with one command.

4.    LET C = A + B

a.   The string variable C receives the value of A + B.
b.   The numerical variable C is assigned the value of A + B.
c.   The string variable C is assigned the expression A + B.
d.   An error message is displayed.

5.    PRINT P\$, Q, R

a.   The expression P\$, Q, R is printed.
b.   The variable Q receives the value of P\$ + R.
c.   Two numerical values and one string value are printed.
d.   An error message is displayed, because 3 variables cannot be printed with one command.

Section Two Format

In this section you will be told what result is wanted from the computer. You must select the line of code that will
cause the computer to produce this result.

6.    Print the sum of two integer variables.

a.   PRINT Z = X + Y
b.   PRINT “Z = X + Y”
c.   PRINT (X + Y)
d.   PRINT SUM(X, Y)

7.    Transfer control to the line labeled “ONE” if the value of a string variable is “YES.”

a.   IF A - “YES” THEN GOSUB ONE
b.   IF A\$ = “YES” THEN GOSUB ONE
c.   GOSUB ONE IF A\$ = “YES”
d.   IF A = “YES” TRANSFER ONE

8.    Print the 24th item of the array B.

a.   PRINT B*24
b.   PRINT B(24)
c.   PRINT ‘B(24)’
d.   PRINT B
9.    Print the word SCORES beginning in the 14th column.

a.   PRINT “SCORES”, 14
b.   PRINT (14) “SCORES”
c.   PRINT TAB(14); “SCORES”
d.   PRINT TAB, 14, “SCORES”

10.   Transfer control to the line labeled “ONE” if X is between 0 and 12 inclusive.

a.   IF X = -12 THEN GOSUB ONE
b.   IF (X > = 0 AND X < = 12) THEN GOSUB ONE
c.   IF X > 12 THEN GOSUB ONE
d.   IF (X > 12 AND X < 12) THEN GOSUB ONE

11.   Dimension the array R\$ to hold 20 string variables.

a.   LET R\$ = 20
b.   LET R = 20
c.   DIM R\$(20)
d.   DIM R(20)

Section Three Format

In this section you will be given a segment of code. Choose the answer that describes the result when this segment
of code is executed.

12.   LET S = 0
FOR C = 1 TO 10
LET S = S + C
NEXT C
PRINT S

a.   The letter S is printed.
b.   The integers from 1 to 10 are printed.
c.   The sum of the integers from 1 to 10 is printed.
d.   An error message is displayed.

13.   LET C = 0
DO WHILE C <= 5
LET C = C + 1
LOOP
PRINT C

a.   0
b.   1
c.   5
d.   6

14.   LET C = 0
DO WHILE C < 12
PRINT P
LET C = C + 1
LOOP
a.   One string value is printed.
b.   Twelve string values are printed.
c.   One integer value is printed.
d.   Twelve integer values are printed.

15.   LET B\$ = ‘0’ + LEFT\$ (‘624’, 1) + MID\$ (‘3549’, 3, 1)

a.   B\$ receives the value 0.
b.   B\$ receives the value 0131.
c.   B\$ receives the value 064.
d.   An error message is displayed because strings cannot be added.

16.   DIM A(3, 12)

a.   A two-dimension array A is dimensioned to hold 36 items of data.
b.   A two-dimension array A is dimensioned to hold 312 items of data.
c.   The third item in the array A is assigned the value 12.
d.   An error message is displayed because DIM is not a legal variable name.

17.   LET X = 3.14159
LET F\$ = "#.##"
PRINT USING F\$;X

a.   3.14159 is printed
b.   3.1416 is printed
c.   3.142 is printed
d.   3.14 is printed

Section Four Format

In this section you will be given a segment of code containing an error. Choose the answer that corrects the error.

18.   FOR I = 1 TO 3
PRINT N\$
NEXT N
DATA “TOM”, “DICK”, “HARRY”

a.   FOR F\$ = 1 TO 3
b.   PRINT “N\$”
c.   NEXT I
d.   DATA TOM DICK HARRY

19.   FOR C = 1 TO 3
PRINT N
NEXT C
DATA 11, ‘TWELVE’, 13

a.   FOR N = 1 TO 3
c.   PRINT ‘N\$’
d.   DATA 11, 12, 13
20.   FOR I = 1 TO 12
NEXT B

b.   FOR I = 1 TO 12
d.   NEXT I

Section Five Format

In this section you will be given an example of output followed by several segments of code. Choose the code that
will produce the given output.

21.   It’s a bird!

SELECT CASE N                                        SELECT CASE N
CASE 1:                                              CASE 1:
GOSUB ONE                                            GOSUB ONE
CASE 2:                                              CASE 2:
GOSUB TWO                                            GOSUB TWO
CASE 3:                                              CASE 3:
GOSUB THREE                                          GOSUB THREE
END SELECT                                           END SELECT
END                                                  DATA 1
ONE:                                                 PRINT "It's a bird!"
PRINT "It’s a bird!"                                 PRINT "It's a plane!"
RETURN                                               PRINT "It's Superman!"
TWO:                                                 END
PRINT "It’s a plane!"
RETURN
THREE:
PRINT "It’s Superman!"
DATA 2
SELECT CASE N                                        1. c    2. a     3. c   4. b   5. c     6. c
CASE 1:
GOSUB ONE                                            7. b    8. b 9. c 10. b        11. c    12. c
CASE 2:
GOSUB TWO                                            13. d    14. d     15. c   16. a       17. d
CASE 3:
GOSUB THREE                                          18. c    19. d     20. d   21. c
END SELECT
END
ONE:
PRINT "It's a bird!"
RETURN
TWO:
PRINT "It's a plane!"
RETURN
THREE:
PRINT "It's Superman!"
RETURN
DATA 1

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 262 posted: 5/1/2010 language: English pages: 5
How are you planning on using Docstoc?