Quiz 2 Name:
_____________________
CPSC 110 ID:
________________________
(c)opyright 2002 Brent M. Dingle Section:
____________________
TA:
________________________
INSTRUCTIONS:
All answers should be PRINTED. If I am not able to easily
read the answer, you will NOT receive any credit for it. Please use a PENCIL
and an eraser (if/when needed).
True or false questions are either right
or wrong – no partial credit.
1. |
True or
False |
A compiler can detect syntax and logical errors. |
|
|
|
2. |
True
or False |
In DOS, the character ‘?’ is a wild character. |
|
|
|
3. |
True
or False |
DOS directories are tree structured. |
|
|
|
4. |
True or
False |
Blaise Pascal is the original creator of the Pascal
programming language. |
|
|
|
5. |
True or
False |
A variable name may have spaces in it. |
|
|
|
6. |
True or
False |
A variable of type integer has NO maximum value that it
can contain. |
|
|
|
7. |
True or
False |
A floppy disk is one example of the main memory used in a computer. |
|
|
|
8. |
True or
False |
Every IF statement must have an ELSE following it. |
|
|
|
9. |
True or
False |
The result of 7 MOD 3 is 2. |
|
|
|
10. |
True
or False |
The decimal equivalent of the binary number 1011 is 11. |
Multiple Choice questions are either right
or wrong – no partial credit.
Answer 11: |
A |
B |
C |
D |
E |
a. The hard disk on which the program was saved.
b. A printout of the program.
c. A CD-ROM with the source code burned on it.
d. A 3 1/2 inch floppy disk with the program saved on it.
e. A picture of the program's output.
Answer 12: |
A |
B |
C |
D |
E |
a. an order set
b. a solution set
c. a procedure
d. an algorithm
e. an implementation
Answer 13: |
A |
B |
C |
D |
E |
a. 16
b. 8
c. 6
d. 4
e. 2
Answer 14: |
A |
B |
C |
D |
E |
a. sum
b. average
c. next
d. first
e. program
Answer 15: |
A |
B |
C |
D |
E |
PROGRAM Shrug;
VAR
num : integer;
BEGIN
Randomize;
num := Random(100);
Writeln(num);
END.
Correct answer is: 0 to 99 (worded however they wanted)
Give one point if they said 1 to
100
Any other answer is no points.
=, <>, >, >=, <=, < 2 points for each correct
Do NOT deduct for any incorrect, such as
!= (unless they also have <>)
char, integer, real, boolean 2 points for each correct
Do NOT deduct for any incorrect, such as
int (unless they also have integer)
:=
(or colon equals)
53
count := 0;
A := 1;
B := 1;
while (count <= 4) do
BEGIN
count := count + 1;
B := B + 1;
A := A + B - count;
write(A, ' '); { there is a space between those single quotes }
END;
Run it and find out, be lenient on the
spacing between numbers.
If they don’t have the correct result then
they get ZERO points.
(hint: excluding comments the first word of a Pascal
program is PROGRAM)
(and if you make a minor syntax error don’t worry about it)
If it prints Howdy to the screen give them
the 5 points.
If it prints other stuff or nothing give
them zero points.
Don’t worry about semi-colons or periods.
assign(out_file, ‘C:\out.txt’); = 2 points
rewrite(out_file); = 2 points
writeln(out_file, ‘Why hello there’); = 2 points
close(out_file); = 2 points
(don’t worry about capital letters or
punctuation)
PROGRAM la;
VAR
count : integer;
BEGIN
count := 1;
while (count
<= 5) do
BEGIN
Writeln(count);
count
:= count + 1;
END;
END.
If you type in what they write and it
doesn’t produce the 1, 2, 3, 4, 5 on separate lines then ZERO points. NOTE:
Missing semi-colons are ok, as is a semi-colon after the do – but circle where
they should be. Variable names will vary.
PROGRAM la;
VAR
num
: integer; 1 point for var
declaration
BEGIN
Writeln(‘Enter
a number from 1 to 10’); 2 pts for prompt
Readln(num); 2
pts for readln
If
(num > 6) then 2
pts for this condition (or equiv)
Writeln(‘Pass’) 1 pt for the output of Pass
Else 2 pts
for this condition (or equiv)
(they
may use an else if or just
another if)
Writeln(‘Fail’); 1 pt for output of Pass
END.
1 point for having anything that counts as
a COMPLETE program (like a program name, a Begin and an End)
Do not be concerned with lack of
semi-colons.
However if they put a semi-colon before an
ELSE or after a THEN you should deduct one point from that ‘condition’ and circle
the semi-colon.
If any of the programs are
difficult/impossible to read or have way too much ‘extra/pointless’ lines of
code you may deduct up to 2 points for every such problem, and make reference
to the instructions at the beginning of the test and at the beginning of the
section – consult with the other TA’s to establish consistency if you do this –
it “shouldn’t” be necessary.
If they took the test using INK make a
note that the directions requested the use of a pencil, but do NOT penalize
them.