for CPSC 110
written by
Brent Dingle
©opyright 2002 all rights
reserved
This is a practice final. It
should illustrate the general layout and types of questions you might find on
the final exam. While this may or may not fully reflect the content of the exam
it should assist in preparing you to take it.
There is no answer key to this
exam. Any questions about a specific problem may be directed towards the
instructor or the TAs.
No answer key will be provided
for this exam. The purpose is for you to learn the material. If you do not know
the answer LOOK IT UP! If AFTER attempting to find the answer you still have
questions, then ask the TAs, then ask the instructor.
This exam is a conglomeration of
questions from quizzes and tests. It may take several hours to complete. The
actual final will likely be much shorter.
I strongly encourage you to look
over the quizzes and tests you actually took, BEFORE doing this practice test.
Good Luck.
TRUE / FALSE
Question (mark ‘a’ for true, ‘b’ for false)
Pascal is a high level language ( T / F ).
A directory can contain only files in it ( T / F ).
A program must be stored in main memory while being
executed by the computer ( T / F ).
A compiler can detect syntax and logical errors (T /
F).
At the end of a program using input and output
files, only the input file must be closed (T / F).
A procedure declaration may contain either
formal parameters or actual parameters (T / F).
The body of a repeat-until loop is always
executed at least once (T / F).
The value of an actual variable parameter CANNOT be
changed by a procedure (T / F).
The control variable of a for loop must
always be of type real (T / F).
The value of a boolean variable must be either true
or false (T / F).
The predefined procedure rewrite will add
output to an existing text file without erasing the old contents of the file (T
/ F).
Formal variable parameters CANNOT have the same name
as actual variable parameters (T / F).
A repeat-until loop continues to execute
until the control expression evaluates to false (T / F).
The value of the control variable in a for loop must start with 1 (T / F).
A for loop can be used to implement the instruction
“repeat the loop body N times” (T / F).
Procedures may change global variables (T /
F).
It is a good idea to modify global variables in a
procedure (T / F).
The value of the boolean expression:
true
and false
is false (T / F).
A function should return more than one
value. T/F
A function may return an (entire) array as a
value. T/F
Array elements may be accessed randomly. T/F
An array may use an enumerated type as an index
range. T/F
Using the Boolean expression 'A' < 'B' will
produce an error when the program is compiled.
T/F
A function may contain local functions and
procedures. T/F
The scope of a local variable of a procedure is the
entire program. T/F
The main body of a program may reference
local variables declared within a procedure.
T/F
When declaring a new data type, a subrange may be of
type real. T/F
Strings can be considered a special type of
array. T/F
When sorting (as described in class and on the web),
a computer can only "see" two items at a time. T/F
The value of a formal value parameter only changes
within the body of a procedure or function.
T/F
A local variable (declared in the VAR section of a
procedure) CANNOT have the same name as a parameter (declared in the formal
parameter list of the same procedure).
T/F
Given that ord(‘b’) = 98 then the function call:
ord(pred('b')) must return the value 99.
T/F
Elements in an array can be of different data
types. T/F
In DOS, the character ‘!’ is a wild character (T /
F).
Pascal always assigns the value zero to all
variables before the execution of a program (T / F).
DOS directories are tree structured (T / F).
Assembly language is a high-level language (T / F).
A floppy disk is one example of the main memory used
in a computer (T / F).
The body of any while loop is always executed at
least once (T / F).
The result of
9 MOD 3 is 3 (T / F).
Every IF statement must have an ELSE
following it (T / F).
Blaise Pascal is the original creator of the Pascal
programming language (T / F).
Alt-F5 compiles a program in the Turbo Pascal
environment (T / F)?
A variable name may have spaces in it (T / F) ?
A variable of type integer has NO maximum value that
it can contain (T / F)?
Charles Babbage was the first programmer (T/ F)?
The interface section of a unit is the public
section (T / F).
When writing a program that uses a unit, the
programmer must know the details of the unit's IMPLEMENTATION section (T / F).
You may NOT create new data types in Turbo Pascal (T
/ F).
A unit can never contain procedures, it may only
contain functions (T / F).
Type real is an ordinal type (T / F).
Variable parameters consume less storage than value
parameters (T / F).
String types may be used as parameter types as
follows:
procedure dostuff(var first, last :
string[10]); (T / F ).
In Pascal the size of an array must be declared at
the time the program is written (T / F).
A record type can have fields holding different
types of data (T / F).
Records and arrays provide a way to give a single
name to a collection of values (T / F).
Pascal allows you to use arrays of arrays (T / F).
Pascal only allows you to use one or two dimensional
arrays ( T / F).
In Pascal, the expression A[1, 2] is the same as
A[2][1] (T / F).
Pascal allows you to create arrays of records (T /
F).
You can “hide” information by placing it in the
implementation section of a unit (T / F).
DOS directories are tree structured (T / F).
Assembly language is a high-level language (T / F).
A floppy disk is one example of the main memory used
in a computer (T / F).
The assignment statement:
n := 35.3;
where variable n is of type integer, is illegal in
Pascal (T / F).
A value parameter of a procedure can be used to
return information back to the main program (T / F)..
The first electronic computer was built using vacuum
tubes (T / F).
Pascal only allows variable parameters (T / F).
The body of any while loop is always executed at
least once (T / F).
The order of parameters in the Procedure declaration
and the procedure call need not match for the program to execute as
desired/correctly (T / F).
A computer can execute a program that is stored in
the secondary memory without loading it into main memory (T / F).
The result of
9 MOD 3 is 3 (T / F).
Every IF statement must have an ELSE
following it (T / F).
Blaise Pascal is the original creator of the Pascal
programming language (T / F).
For the next questions ( a = compile, b = compiles and runs, c = neither)
Given:
VAR
a : array[-10..10] of char; { yes this really compiles, it’s just a bad way to do it } .
i : integer;
x and i are the ONLY variables declared.
And i is initialized to 5. i.e. there was a line that said i := 5;
a[ i ] := ‘a’; { a = compiles, b = compiles AND runs, c = neither }
a[ i + 26 ] := ‘l’; { a = compiles, b = compiles AND runs, c = neither }
a[ i + 2 ] := ‘S’; { a = compiles, b = compiles AND runs, c = neither }
a[ i -8 ] := ‘4’; { a = compiles, b = compiles AND runs, c = neither }
a[2] := ‘q’; { a = compiles, b = compiles AND runs, c = neither }
a[-5] := ‘o’; { a = compiles, b = compiles AND runs, c = neither }
a[99] := ‘w’; { a = compiles, b = compiles AND runs, c = neither }
For the next questions consider the below:
Fill in the blanks below so that the below WHILE
loop would output:
1 4 7 10 (all on the same line)
N := 1;
REPEAT
_BLANK
1__ := N + _BLANK 2_ ;
write(_BLANK
3_, ‘ ‘ );
UNTIL (N >
_BLANK 4_ )
1.
Blank
1 should be replaced by:
a.
3
b.
5
c.
7
d.
9
e.
N
2.
Blank
2 should be replaced by
a.
3
b.
5
c.
7
d.
9
e.
N
3.
Blank
3 should be replaced by
a.
3
b.
5
c.
7
d.
9
e.
N
4.
Blank
4 should be replaced by
a.
3
b.
5
c.
7
d.
9
e.
N
MULTIPLE CHOICE – Select the best answer.
ASSUME NO SYNTAX ERRORS IN CODE.
The compiler translates a high level language to:
another high level language
English
machine instructions
pseudo-code
none of the above
Assume that the only files in the current directory
are
progm1.pas, progrm1.pas,
progm2.pas and program.pas.
What command will ONLY remove the files progm1.pas and progm2.pas ?
(i.e. program.pas and progrm1.pas will not be
removed, but the other two files will be)
remove pr*.pas
remove progm*.pas
remfiles progm1.pas progm2.pas
erase progm*.pas
erase prog*.pas
Which of the following is the method to get to the
root directory from one of its subdirectories?
cd
cd \
cd root
cd \root
none of the above
Which of the following is responsible for the
arithmetic or logical calculations in a computer?
mouse
memory
central processing unit
all three of the above (a, b and c)
none of the above
Which of the below commands is the easiest way to
copy all the files from one floppy to another?
cp a: b:
cp a:*.* b:*.*
transfer a: b:
copyall a: b:
diskcopy a: b:
Which of the following are input devices?
keyboard and monitor
monitor and printer
mouse and monitor
central processing unit
mouse and keyboard
Which of the following is NOT a legal Pascal
Variable?
_ABC123
A_BC123
A_2BC13
2_ABC13
A_BC_321
Which of the below declarations will cause the
statement:
x := y;
to be in error?
VAR
x: char;
y: char;
VAR
x: real;
y: integer
VAR
x: real;
y: real;
VAR
x: integer;
y: integer;
VAR
x: integer;
y: real;
What is the output of the below code (assume it is
embedded in a working program)
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;
0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
1 1 1 1 1
0 0 0 0 0
The next 2 questions pertain to the following code
(assume the code has NO syntax errors and compiles)
Program confuse;
VAR
x, y : integer;
{ Procedure
swap places the value of U in Z and the value of Z in U }
Procedure Swap( Var U, Z : Integer);
VAR
Temp : Integer;
BEGIN
Temp := U;
U : = Z;
Z := Temp;
END;
BEGIN {
Program }
x := 1;
y := 2;
swap( x, y);
swap( y, x);
swap( x, y);
write(' x = ', x);
swap( y, x);
writeln(' y = ', y);
END.
The FORMAL parameters of Procedure Swap are:
U, Z, Temp
X, Y, Temp
U, Z
X, Y
X, Y, U, Z, Temp
The output of the program is:
x = 2 y = 2
x = 1 y = 2
x = 2 y = 1
x = 1 y = 1
none of the above
What is the output of the following program segment
(assume embedded in working code)
VAR n :
integer;
BEGIN
n := (7
DIV 3);
writeln(n);
END;
1
2
3
0
2.3333333333
What is the output of the following program segment?
(assume embedded in working code)
x := 10;
while ( x > 0 ) do
x := x – 4;
writeln(x, '
'); { There are several spaces between the single quotes }
6 2 –2
6 2
0
2
–2
A logical error is:
a typing mistake
a mistake in the underlying algorithm
when logic circuits of the computer fail
all of the above
none of the above
Which of the following is not an input device?
keyboard
mouse
scanner
monitor (like the ones in your lab)
all the above are input devices
In this class, a set of instructions that leads to a
solution is called a(n) ?
solution set
procedure
algorithm
order set
implementation
Which of the following does NOT make source code
easier to read?
comments
indentation
semicolons
both A and B
A, B and C
Which of the following is NOT part of a procedure?
heading
subject
body
both A and B
A, B and C
Which of the following identifiers represents a loop
structure?
if-then-else
loop
while-do
procedure
none of the above
The rules of grammar for a programming language are
called the
grammar
rules
statements
ontology
syntax
Which of the following is the assignment operator in
Pascal?
=
:=
= =
->
=>
In the following statement, which mathematical
operation will be performed first (aka has the higher precedence) ?
X + Y * Z – W / A;
*
/
+
–
log
Which identifier BEGINS a comment in Pascal?
//
/*
(*
[
}
Which following structures assists the programmer in
top-down design?
procedure
while-do
if-then-else
loop
none of the above
What type of variable would the following value be
assigned to: 'Why, hello there'
integer
real
string
complex
char
What would be the output of the following
expression?
2 * 4 – sqrt(abs(-16)) / 2
0.0
6.0
2.0
3.0
None of the above
Given the following piece of code (embedded in a
working program, assume no syntax errors):
VAR
score : integer;
grade : char;
BEGIN
grade := 60;
if (score >= 60) then
grade :=
'p'
else
if (score <= 60) then
grade :=
'f';
END.
What is the final value of grade (when the program
ends)?
p
f
pf
fp
undetermined
Which of the following is an illegal Pascal
expression (assume all variables are declared correctly)
2 * 5 * n – sqrt(20) / 2;
x / (( 1 – y / 100) / z );
p * q / 100 – r;
amount * ( 1 + rate / 100);
all the above are legal
In the following program segment (assume no syntax
errors and embedded in a working program)
VAR
x, y :
integer;
BEGIN
x := 3;
y := 5;
if 2 > x then
y := 1
else
x := 5;
if 4 < x then
y := 2;
END.
What is the final value of y ?
1
5
2
non-determinate; y may not be assigned a value
none of the above
What does the operator <> mean in Pascal ?
greater than
equal to
not equal to
less than
none of the above
What does the operator != mean in Pascal ?
greater than
equal to
not equal to
less than
none of the above
Which of the following is NOT a valid Pascal
function ?
trunc(3.43);
abs(-36);
sqrt(35);
square(3);
exp(3.3);
Which of the following is an illegal actual value
parameter of type integer? (Assume the variable n is of type integer).
34 / 3
n + 1
26
n
All the above are legal
How many bytes is a Kilobyte ?
25
64
1024
100
1 million
How many times is "Howdy" printed by the
below code (assume embedded in working program with no syntax errors):
VAR
count :
integer;
BEGIN
count :=
5;
while
(count > 1) do
begin
writeln('Howdy');
count
:= count – 1;
end;
END.
3
4
5
infinite number of times (or until computer breaks
or is turned off)
none of the above
Which of the following is NOT a reserved word in
Pascal?
program
begin
end
const
comment
Which of the following statements is FALSE about
comments in a program?
they increase readability
they are compiled to machine language by the
compiler
they provide program documentation
all the above are true
both b and c are false
What is the output of the following program segment
(as always, embedded in working program and no syntax errors):
writeln('Howdy, '); { there is a space
before each ending single quote }
write('Good ');
writeln('Luck ');
Howdy,
Good
Luck
Howdy, Good Luck
Howdy, Good
Luck
Howdy,
Good Luck
None of the above
What is the output of the following program (assume
no syntax errors)?
program SeeIt;
VAR
x, y :
integer;
procedure Bob(x, y : integer);
BEGIN
writeln(x, ‘ ‘, y, ‘ ‘);
{ There is a space between the
single quotes }
END;
BEGIN {
program }
x:= 1; y
:= 2;
Bob(x, y);
Bob(y, x);
END.
1 2 1 2
1 2 2 1
1 2
2
2 1
2
1 2
1
Which of the following is NOT a type of parameter
(discussed in the book)?
formal
concrete
actual
variable
value
What is the decimal (base ten) representation of the
binary number: 00101 ?
5
6
7
11
3
What is the output of the following program? ( Assume no syntax errors )
program Just;
VAR
i :
integer;
BEGIN
i := 0;
while (i < 5)
do
writeln(i, ‘ ‘); { There is a space between the single quotes }
END.
0 1 2 3 4
0 1 2 3 4 5
0
no output
the program loops forever outputting 0
What is the output of the following program? (Assume
no syntax errors)
program YetAgain;
VAR
i, k :
integer;
BEGIN
i := 1;
k := i +
1;
while (i
<= k) do
begin
if (i
MOD k = 0) then
i
:= k + 1
else
i
:= i + 1;
end; { of while }
writeln( i
);
END.
1
2
3
4
the while loop is infinite, so nothing is ever
output
The next TWO questions refer to the below code
(assume no syntax errors):
program YetAgainAndAgain;
VAR
i, k :
integer;
Procedure AddAndIncrement( var u : integer, z :
integer );
begin
u := u +
z;
z := z +
1;
end;
BEGIN
i := 3;
k := 2;
AddAndIncrement (i, k);
writeln(
i, ‘ ‘, k); { there is a space between the single quotes }
end; { of
while }
What is the value of i that is output ?
2
3
4
5
6
What is the value of k that is output ?
2
3
4
5
6
What is the output of the following piece of code
(assume embedded in working program and no syntax errors):
dollars := 9876.54321;
writeln( ‘$’, dollars:0:1);
$6.54321
$6.5
$9876.543
$9876.54
$9876.5
Which of the following is NOT a correctly formed
constant of type REAL (according to Pascal)?
.89
98.6
–32.0
5.22
11.278
Which of the following can never be used as a
variable name in Pascal?
sum
average
next
first
program
In Pascal, procedure declarations are placed:
after the main body of the program
after the variable declarations and before the main
body
within the main body
before the (global) variable declarations
anywhere you like
Which of the following is an illegal assignment
statement (assume all variables properly declared)?
x := x + y;
pRoWd := good + job;
avg := 9 + 4 + 8 / 4;
5 := b;
times := 1 + 4 + 22;
Today in the U.S. the pseudocode of an algorithm is
written in
low level language
mix of English and high level language
mix of English and low level language
ancient Greek or Egyptian
all of the above
The first general purpose, purely electronic digital
computer was:
TI – 83
Colossus
ENIAC
Mark I
Atari 2600
What “generation” of computer are we currently
producing?
second
third
fourth
fifth
sixth
How many bits are in a byte?
1
2
4
8
16
Which of the following is NOT a key hardware
component?
operating system
CPU
main memory
secondary memory devices
input / output devices
If a unit named Bob is in a file UNIT1.PAS and you
compile it to disk, the compiled version
of the unit will be in a file named:
BOB.TPU
BOB.PAS
BOB.TXT
UNIT1.TPU
UNIT1.TXT
Given the below 4 types of declarations:
1. Constant Declarations
2. Variable Declarations
3. Type Declarations
4. Procedure and Function Declarations
What is the order the book says they should be done
in a program?
1, 2, 3, 4
1, 3, 2, 4
4, 2, 1, 3
4, 3, 2, 1
3, 4, 2, 1
In the book ADT stands for which of the following:
Aggies Dominate Texas
Abstract Down Time
Any Darn Thing
Abstract Data Type
AqueDuct Turnpike
Which of the following is the correct declaration
for an array?
A = array [1..10] of integer;
A = array of [1..10] integer;
A = integer[1..10] of array;
A = integer array of [1..10];
none of these
If the below statement was placed in a working a
program (assume ch is type char):
ch := succ(‘G’);
What is the value of ch after the above statement is
executed?
F
K
h
H
f
If the below statement was placed in a working
program (assume val is type integer):
val := ord( ‘M’ ) –
( ord( ‘L’ ) );
What is the value of val after the above statement
is executed?
0
1
2
–1
–2
Given the following type declaration:
type
BigOnes = 9..15;
The host type of BigOnes is:
char
boolean
integer
real
string
In the statement:
Score[ I + 3 ] := 5;
I + 3 is the:
Array Name
Subscript
Value of the array element
All of the above
None of the above
To execute a Bubble Sort with a size 10 array we
will need to
make at most, ______ passes through the array.
10
5
9
0
None of the above
Assume the following code is embedded in a working
program.
Also assume that the array A has been properly
declared as an array of type integer and has been loaded with data. Further
assume Element and Sum are type integer.
Sum := 0;
For Element := A[1] to A[100] do
Sum := Sum + Element; { This
is the statement line referred to in the question }
How many times does the statement in the for loop
get executed?
once
one hundred times
99 times
101 times
Can’t say, it depends on the values of A[1] and
A[100].
The next 2 questions refer to the below program:
program OutPut;
type
ListArry =
array[1..6] of char;
var
i :
integer;
message :
ListArry;
begin
message
[1] := ‘O’;
message
[3] := ‘L’;
message
[6] := ‘?’;
message
[5] := ‘H’;
message
[2] := ‘L’;
message
[4] := ‘E’;
for i := 6 downto 1 do
write(message[i]);
end.
What is the output of the above program?
HELLO?
?OLLEH
HELLO
?HELLO
There is no output
"message" is best described as:
an array of ListArry elements
an array of char elements
an array of integer elements
an array of type letters
none of the above
To enter data into a 2-dimensional array in
ROW-major order,
the INNER loop should control which subscript?
Column subscript.
Row subscript.
It doesn't matter.
Nested loops are not needed.
None of the above.
Which of the following is NOT a “built in” string
function/procedure in Turbo Pascal?
length
insert
copy
reverse
pos
What is the output of the below program ?
program AddStuff;
const
MAX_SIZE
= 5;
type
score_array = array[1..MAX_SIZE] of integer;
var
i, j, x :
integer;
scores :
score_array;
begin
for i:= 1
to MAX_SIZE do
scores[i] := i;
x := 0;
for j := 1
to MAX_SIZE-2 do
x := x
+ scores[j];
writeln(x);
end.
none of the below
3
6
10
15
Which of the following are ordinal types:
I.
boolean
II.
string
III. real
I
II
III
I and II
I and II and III
If the following statement is placed in a working
program what is the value of p after the statement
is executed (assume p is type integer) ?
p := pos(‘be’, ‘dobedobedo’);
3
4
5
6
7
How many elements are in the following
multi-dimensional array?
Var
Test :
array[‘A’..’D’,’a’..’d’] of integer;
2
4
8
16
none of the above.
The next 3 questions assume the following
declarations:
Type
Aggie =
array [1..10] of integer;
Var
A, B, C :
Aggie;
i, j, sum
: integer;
What does the following piece of code do given the
above declarations and assuming it
is embedded in a working program ?
For i:= 1 to 10 do
A[i] :=
B[10 - i + 1];
Copies the array B to A
Copies the array A to B
Stores in B, the reverse array of B.
Stores in A, the reverse array of B.
None of the above.
Given the above declarations and assuming it is
embedded in a working program, what does the following piece of code do ?
for i:=1 to 10 do
begin
sum :=
A[i];
A[i] :=
B[i];
B[i] :=
sum;
end;
Reverses the contents of both A and B.
Swaps the contents of A and B (i.e. When the loop
completes, the content of A = what the content of B was before the loop and the
content of B is what the content of A was before the loop)
Finds the sum of the contents of A and B.
Copies the contents of A into B, leaving A unchanged.
None of the above.
If we want to add the arrays A and B elementwise and
store the result in the array C
(i.e. C[i] := A[i] + B[i];) how many cells from A, B
and C do we have to access?
10
20
30
60
none of the above.
The individual components of a record are commonly
referred to as:
fields
components
component fields
all of the above
none of the above
The next 3 questions refer to the below code:
program FoodBill;
type
DeptName
= (Meat, Deli, Produce, Grocery);
AmountSpent = array[DeptName] of real;
ExpenseArray = array[1..50] of AmountSpent;
var
SpentOn
: AmountSpent;
CustomerExpense : ExpenseArray;
temp :
real;
function Total(var B: AmountSpent) : real;
var
Dept:
DeptName;
Sum :
real;
begin { Total
}
Sum := 0;
for Dept
:= Meat to Grocery do
Sum :=
Sum + B[Dept];
Total :=
Sum;
end; { Total }
begin { main }
SpentOn[Meat] := 40.0;
SpentOn[Deli] := 0.0;
SpentOn[Produce] := 10.00;
SpentOn[Grocery] := 45.00;
temp :=
Total(SpentOn);
writeln(temp:0:2);
end. { main }
What is the output of the above code.
95.00
100.00
40.00
45.00
none of the above
In the above code the variable SpentOn is:
an array of arrays
a 1-dimensional array
a 3-dimensional array
a 4-dimensional array
not an array
In the above code the variable CustomerExpense is:
an array of arrays
a 1-dimensional array
a 3-dimensional array
a 4-dimensional array
not an array
The next 3 questions refer to the below code:
program MultiIndex;
type
GradeArray
= array[1..3, 1..6] of integer;
var
MyArray
: GradyArray;
index, j
: integer;
q, r, s
: integer;
begin { main }
for index
:= 1 to 3 do
begin
for j :=
1 to 6 do
begin
if (index > j) then
MyArray[index, j] := index - j
else
MyArray[index, j] := j – index;
end; { for j }
end; { for index }
q :=
MyArray[3, 3];
r :=
MyArray[2, 1];
s :=
MyArray[3, 6];
{ The questions will ask for the values of
q, r, s at this point in the code }
writeln(q, ' ', r, ' ', s);
end.
What is the value of q that is output?
0
1
2
3
–1
What is the value of r that is output?
0
1
2
3
–1
What is the value of s that is output?
0
1
2
3
–1
The next 3 questions refer to the below code:
program ArrayStuff;
type
array_type : array[1..5] of integer;
var
A, B :
array_type;
index,
x, y, z : integer;
begin
for
index := 1 to 5 do
begin
A[index] := index + 1;
B[index] := index;
end; { for }
B := A;
B[3] := B[3] –2;
x :=
B[3];
y :=
A[3];
z :=
B[4];
{ The questions will ask what the value of
x, y, z are at this point in the code }
writeln(x, y, z);
end.
What is the value of x that is output?
1
2
3
4
5
What is the value of y that is output?
1
2
3
4
5
What is the value of z that is output?
1
2
3
4
5
To perform a binary search through an array, the
data must be _________.
in random order
ordinal
sorted
integers
none of the above
A program that uses a unit may reference:
I. any
procedure and function found in the unit
II.
declarations found in the interface section of the unit
III. declarations found in the implementation
section of the unit
I
II
III
all of the above
none of the above
Given the below declarations:
type
Sample =
record
F1 : integer;
F2 : char;
end;
var
X1, X2 :
Sample;
Assume the following code is embedded in a working
Pascal program:
X1.F1 : = 5;
X1.F2 := ‘A’;
write(X1.F1, X1.F2, ‘ ---- ‘);
X2 := X1;
X2.F1 := 6;
X1.F1 := 4;
writeln(X2.F1, X2.F2);
What is the output (of the above code)?
6A ---- 5A
5A ---- 5A
5A ---- 6A
6A ---- 6A
5A ---- 4A
Given the below declarations
Type
OneToFifty = 1..50;
ILoveTests = array[1..50] of integer;
Var
A, B :
ILoveTests;
X, Y :
OneToFifty;
Assuming no subscript range errors, which of the
following statements is NOT allowed?
A[X][Y] := B[X][Y];
A[B[X*Y]] := X;
A := B;
B := A;
None of the above are allowed.