o
Section:
__________________________
TA:
Also write YOUR name
and TAs name on the cover sheet of the test and on the scantron.
If you have any questions
during the test, raise your hand and someone will come to you. It is wise to
mark your answers both on the scantron and on this test paper. You MUST mark
them on the scantron.
Unless otherwise noted assume that ALL code pieces are embedded in a working program
with NO syntax errors.
TRUE / FALSE Question (mark a for true, b for false)
MULTIPLE CHOICE Select the
best answer. ASSUME NO SYNTAX ERRORS IN CODE.
a.
VAR
x: char;
y: char;
b.
VAR
x: real;
y: integer;
c.
VAR
x: real;
y: real;
d.
VAR
x: integer;
y: integer;
e.
VAR
x: integer;
y: real;
a.
Procedure
GetNumber( var Number: real);
b.
Procedure
MoreStuff( x, y: real);
c.
Procedure
AddThem( 2big : real; value: integer);
d.
Procedure
SumIt( var P, B: real; var N: integer);
e.
Procedure
Read_Name;
a.
subjugate
and rule design
b.
top-down
design
c.
bottom-up
design
d.
piece-meal
coding
VAR n : integer;
BEGIN
n := (10 DIV 3);
writeln(n);
END.
a.
3.333333
b.
0.333333
c.
1
d.
2
e.
3
a.
reset
b.
output
c.
open
d.
append
e.
write
a.
keyboard
b.
mouse
c.
scanner
d.
monitor
(like the ones in your lab)
e.
all
the above are input devices
a.
NOT
( true or false)
b.
12
mod 4 = 3
c.
(5
= 6) OR (10 > 5)
d.
NOT
( 5 <= 10)
e.
true
and false
a.
grammar
b.
rules
c.
statements
d.
ontology
e.
syntax
Program lala;
VAR
n
: integer;
BEGIN
n
:= 2;
While
( n < 0) do
begin
writeln(n,
); { there is a space
between the single quotes }
n
:= n + 1;
end;
END.
a.
there
is no output
b.
2
1
c.
2
1
0
d.
2
1 0
e.
2
1
a.
sqrt(25);
b.
square(5);
c.
exp(7.3);
d.
trunc(543.67);
e.
abs(-67);
The next two
questions refer to the procedure declaration:
PROCEDURE Example(A: integer; var B:
integer);
a.
modular
parameters
b.
formal
parameters
c.
actual
parameters
d.
initial
parameters
VAR
count
: integer;
BEGIN
count
:= 1;
while
(count < 5) do
begin
writeln('Howdy');
count := count 1;
end;
END.
a.
3
b.
4
c.
5
d.
infinite
number of times (or until computer breaks or is turned off)
e.
none
of the above
a.
(5
+ y >= 6) or (x < 50)
b.
(y
> 2*x) and ( x > 2*y)
c.
(x
> 3) or (y>5)
d.
(x
> 45) and ( 8 / (x 2 ) > 1)
N:= 1
REPEAT
FOR M:= 2 DOWNTO 1 DO
Begin
Write(N * M,
); { there is a space between
those single quotes }
End;
n := n + 1;
UNTIL
N = 1;
Writeln;
a.
there
is no output or none of the below
b.
2
1
c.
2
1 4 2
d.
1
2
e.
1
2 2 4
a.
(X
= e) and (X = y) and (X = a)
b.
(X
= a) and (X = e) or (X = y)
c.
(X
= e) or (X = a) and (X = y)
d.
(X
= e) or (X = y) or (X = a)
a.
they
increase readability
b.
they
are compiled to machine language by the compiler
c.
they
provide program documentation
d.
all
the above are true
e.
both
b and c are false
PROGRAM
Loop;
VAR
check:
Boolean;
BEGIN
Check
:= False;
REPEAT
Writeln(Howdy);
check
:= NOT( Check);
UNTIL NOT( check );
END.
a.
0
b.
1
c.
2
d.
infinite
loop
(assume embedded in a working program and number is
type integer):
number : = 3;
CASE number OF
0..3
: Writeln(first);
4 : Writeln(second);
5 : Writeln(third);
6..9
: Writeln(fourth);
ELSE
Writeln(odd);
a.
first
b.
second
c.
third
d.
fourth
a.
Stuff(4,
A, 4 + B);
b.
Stuff(A,
4 + B, B);
c.
Stuff(A,
B, 4);
d.
All
of the above
assign(file1, 'data3.txt');
rewrite(file1);
assign(file2, 'data1.txt');
reset(file2);
assign(file3, 'data2.txt);
append(file3);
program SamIAm;
VAR
x, y :
integer;
procedure GreenEggs(x, y : integer);
BEGIN
writeln(x, , y,
); { There is a space between the single quotes }
END;
BEGIN {
main program }
x:= 2;
y := 1;
GreenEggs ( x, y );
GreenEggs ( y, x );
END.
a.
2
1 1 2
b.
1
2 2 1
c.
2
1
2 1
d.
2
1
1 2
e.
1
2
2 1
a.
5
b.
6
c.
7
d.
11
e.
3
a.
after
the main body of the program
b.
after
the variable declarations and before the main body
c.
within
the main body
d.
before
the (global) variable declarations
e.
anywhere
you like
a.
BobHope
b.
howdy
c.
ghj723
d.
div
e.
lark
The
following question refers to the below code (assume working and no syntax
errors):
PROGRAM counting;
VAR
i, j:
integer;
BEGIN
for i :=
0 to 2 do
begin
for j := 0 to 2 do
Begin
writeln('came here');
End
end
END.
Could
it be? Is it possible? Why yes, I think it is
this is the end of the
test!!!!!!!!!