Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
TEKNOLOGI
PETRONAS
FINAL EXAMINATION
SEPTEMBER 201 4 SEMESTER
INSTRUCTIONS TO CANDIDATES
Note : There are TWENTY FouR (24) printed pages including the cover page.
SECTION A
[40 Marks]
A. RAM drive.
B. ROM drive.
C. Flash drive.
D. Thumb drive.
A. input
B. output
C. process
D, numbers
3' Which of the following expressions is the best to represent 0 < marks < 100
in PASCAL?
2
FATOOl 5
A. begin
B. string
c. integer
D. character
A. constants
B. identifiers
C. operators
D. comments
FATOOl 5
A. fatal
B. logic
C. run time
D. warning
11. which one of the following is TRUE about procedure and function?
13. lf the formal parameter is declared with var, which of the following will
return error?
A. Line 1
B. Line 3
c. Line 8
D. All lines
A. Sqrt (x)
B. Pow (x, y)
c. Round (x)
D. upCase (x)
16. What would be the heading for a function called High, if it has two real
parameters, and returns the larger of these two real numbers?
A. I , ll and lll
B. l,ll andlV
c. l, lll and lV
D. All of the above
18. Before data values can be read from a file, the file must be prepared by
executing a(n) statement referencing the file variable.
A. read
B. write
C. reset
D. append
t. Real
il. lnteger
il1. Character
tv. Enumerated
A. I , ll and lll
B. l,ll andlV
c. ll, lll and lV
D. All of the above
FATOOl s
20' Rearrange these statements of operation on how to use the Text file.
A. Var
B. Nested
C. Boolean
D. Recursion
A. 5+3*2-6DlV2
B. 5+3MOD2-6DlV2
C. 5*3+12l6DlV(2+2)
D. NOT (S +3* 2-6 DtV 2, O)AND (S + 3 MOD 2= 10)
FATOOlS
L eoRAANDc
II. NOT(BORC)ORA
lll. Nor B oR (c oR NoT A)
IV. C OR ( A AND (B OR C))
A. l, ll and lll
B. l, ll and lV
C. l, lll and lV
D. ll, lll and lV
25. Choose the CORRECT statements to fix the syntax error in Question 24.
A. l, ll and lll
B. l, ll, lll and lV
C. l, lll, lV and V
D. l, ll, lll, lV and V
26. Which statement will return logic error and not related to the given TABLE Q26?
TABLE Q26
Symbol Points
$ 90-1 00
# 80-89
@ 60-79
& 50-59
*
40-49
10
FATOOlS
A. Head section
B. Body section
C. Declaration section
D. Head, declaration and body section
11
FATOOl 5
30' Randomization is used to get the random number. lts parameter is the
highest possible number that can be generated. suppose:
num::random(30); it means that num will contain any integer number
between
A. 0to29
B. 0to30
C. 1to29
D. 1to30
Based on the declaration in FIGURE e31, what is the output when the following
program is executed?
12
31. for i::1 to 3 do
begin
xlil :: i;
ytil :: xlil * xlil;
end;
z .: (1 .
v,
A.
B.
c.
D.
x :: {1, 5, 3};
ifx[0]=Lthen
x:--x-3;
else
v .:
.
QO.
JJ
'
A.
B.
c.
D.
13
FATOOlS
4.2
8.9
c. 10
D. whatever
14
FATOOlS
Writ.eln(,el-se, );
end;
A. 10
B. 20
C. else
D. Syntax error
15
For Question 36 to 40, refer to the declaration in FTGURE e36.
var
x, y : arrayt1..5l of integer;
z, i : integer;
where a procedure or function is involved, the declaration
is shown in the accompanying comment.
Based on the declaration in FIGURE e36, what is the output when the following
program is executed?
A. 1#4#5
B. 2#8#5
c. 1#4#5
2#8#5
D. lnfinite loop
16
FATOOl 5
A. I
8.2
c.3
D. Syntax error
17
39. for i:: 1 to 5 do
x[i] :: i * i;
z :: count (x) ;
writeln (z) ;
{ where count has been declared as folows:
procedure count (arr : array of integer)
var
i, c : integer;
.: n.
v,
for i:=1 to 5 do
c :: c + arr[i];
count i: c;
4.0
B. 50
c. 54
D. Syntax error
19
FATOOl 5
40. i := 0;
repeat
writel-n(i:i);
i:=t+2;
ifi>10then break;
until fal-se;
A. 0246810
8.0
2
4
6
I
10
c.0
I
10
D. lnfinite loop
20
FATOOl 5
SECTION B
[60 Marks]
[8 marks]
[2 marks]
21
FATOOl 5
21 11 2014
6
4141 60"5
cD42 80.5
F0153 60
4404 55,5
4481 75
83616 85
FIGURE Q2
The first non-blank line in the file contains the day, month and year for the
measurement. The second non-blank line in the file contains an integer that
indicates the number of lines of data in the file. Each line of data contains the
following sequence of data: machine id and temperature.
a' Draw a flowchart for a program that reads the name of a data file from the
user, reads the file, computes the minimum, maximum and average
temperature for the machines listed in the file, and write out to a report file
that has a format as shown in FIGURE e2(a):
FIcURE a2(a)
[10 marks]
22
FATOOls
b. Discuss why, in this particular case, using a file would be more appropriate
as compared to performing input and output interactively.
[2 marks]
[8 marks]
FATOOl 5
FIGURE Q3
[4 marks]
[7 marks]
[9 marks]
- END OF PAPER -
24