Sept14 Tcb2073 Structured Programming and Database System
Sept14 Tcb2073 Structured Programming and Database System
TEKNOLOGI
FINAL EXAMINATION
SEPTEMBER 201 4 SEMESTER
COURSE
TCB2O73
DATABASE SYSTEM
DATE
TIME
9.00 AM
INSTRUCTIONS TO CANDIDATES
SECTION A
SECTION B
1.
2.
3.
arriving
in
assumptions.
5
until
instructed.
Note
Universit.i Teknologi
PETRONAS
TCB2073
SECTION A
[40 Marks]
1.
A.
B.
C.
D.
2.
input
output
program
compiler
A.
B.
C.
D.
))coEmitted<<
>>kifometre;
3.
i.
ii.
iii.
iv.
A.
B.
C.
D.
i, ii, iii, iv
i, iii, ii, iv
ii, i, iv, iii
ii, i, iii, iv
2
TCB2073
4.
i.
ii.
iii.
iv.
A.
B.
C.
D.
5.
iand
ii
iand
iii
iand iv
All of the above
int qmarkcode:, ?, ;
cout<<"ASCII code for ? :,,<(qmarkcode<(endl;
A. ASCII code for ? : ?
B. ASCII code for ? : 62
C. ASCrr code for ? :qmarkcode
D. ASCrI code for ? :qmarkcodeendl
6.
A.
B.
C.
D.
7.
0<= n <=100
0<= n ll n<=100
0<= n && n<=100
! (0<= n && n<=100)
what will be the result for calling the predefined function below?
ROUND (235-615);
A.
B.
C.
D.
235
236
23s.1
235.6
TCB2073
8.
int
{
main
cout<<"Heffo
Wor_Id"<<end1 ;
cout(("Hello
",'
cout(("!Vorl-d"
cout ((
"Vor
Id"((endl
cout{(
"He
l-o";
l-
coutd<"Hell-o World"{(endl
A. Hello
World
HeIfo Vorldorl_d
HelfoHelIo forld
B. Heffo worl-d
HeIlo worldworl-d
Hellohelo world
C. Hello world
Hel-l-o Vorl-d
lVorld
Heffo
Hello
Worfd
D. Heflo world
Hello
V'lorld
World
Helfo
Hefl-o
Vrlord
TCB2O73
9.
Choose the GORREGT formula from the following expression, which will
produce 27.0 asthe end result.
A. 10+5.2-612
B. (10 + 5).2-612
C. (10+5*2-6)12
D. ((10+5).2-6)t2
10.
A.
B.
C.
D.
11.
j+j:25;
k: sum + 5;
amount : $10++;
p+p+p:total;
A.
B.
C.
D.
12.
j+):25;
k: k+26i;
amount +: 10;
p+p+:total;
consider the following variable names and choose the GORREGT one.
i. variabl-e 3
ii. sum of g
iii. _addressEmployee
iv. 2rtne score
V. discountGstore
A.
B.
C.
D.
TCB2073
first 40 hours pay rate is RM5.00.The pay rate after the first 40 hours is
RMs.50. The maximum working hours is only 60 hours. when the working
hours is more than 60 hours, the program will display appropriate message
and will not calculate the weekly salary.
FIGURE Q13
3.
ln solving the problem, what could be the input and output of the program?
A.
B.
C.
D.
4.
Which statements are the valid steps to process the input and output (in
sequence)?
A.
B.
C.
D.
salary
'15.
A.
B.
C.
D.
Input
Input
Input
Input
TCB2073
Question 16,17 and 18 refer to the following C++ statements in FIGURE Q16.
int
{
exampleRecursion
if (n::0
return
(int
n)
0;
el- se
return
FIGURE Q16
16.
A.
B.
C.
D.
17.
A.
B.
c.
D.
18.
25
32
36
42
A.
B.
C.
D.
exampleRecursion (-1)
exampleRecursion(O)
exampleRecursion (1)
exampleRecursion (999);
TCB2O73
#include (iostream)
using namespace std;
cout
cout
)
int main (
{
print(10);
print ( 10 . 10 ) ,' return
0;
FIGURE Q19
19.
A.
Here is int 10
Here is int 10.10
B.
Here is float 10
C.
Here is int 10
Here is float 10.10
D.
Here is float 10
Here is int 10.10
20.
A.
B.
C.
D.
function
to display string
TCB2073
21.
A.
B.
c.
D.
22.
epy)
1nt temp;
temp:px,'
px:py;
py:temp;
)
lnt
{
main
int a: I0,b:20;
swap (a,b);
cout((a((" "((b((endf
return 0;
A.
B.
C.
D.
TCB2O73
23.
int
py)
temp;
temp:px;
px:py;
py:temp;
i nt
main
int a: I0,b--20;
sv/ap (a,b) ;
cout((a((" "((b((endl;
return 0;
A.
B.
C.
D.
24.
10 20
10 10
20 10
20 20
What is the data type for variable data in the C++ statements below?
data
25.
til:0;
A.
int
B.
aay
c.
vector
D.
double
A.
B.
C.
D.
10
TCB2073
26.',
A.
B.
C.
D.
27.
'
The expression
A.
B.
C.
D.
28.
is vatd.
is invalid,
int main ( )
11
coRREcr
output.
TCB2O73
29.
A.
B.
C.
D.
at
the
Question 30, 31 and 32 refer to the following C++ statements in FIGURE Q30.
int
main
int t,)
int
va1 [3
0;
FIGURE Q3O
30.
A.
B.
c.
D.
816315r425
B,16,g,52,3,15,2'l,6,14,25,2,rO
B 16 9 52 3 1s 21 6 14 25 2 10
0x22ff00 0x22ff00 0x22ff10 Ox22ff10 0x22ff2o
0x22ff20
12
TCB2O73
31_
Assuming that int total is intialize to 0, which C++ statements will total
up all elements in array va1?
A.
B.
D.
13
TCB2073
32.
A.
,3, r4?
for(j:0;1<4;j++
cout((vaf Ir] tj I <<"
i+:3;
B.
",.
+:3;
C.
for(j:0;j<4;1++1
cout((val tiI ij I <<" ";
j +:3;
D.
+:3;
for(j:0;j<4;)r+1
{
14
TCB2073
33.
int main (
6.'7 } ;
void
show
(double vafs []
int i:0;
while (i<4)
{
cout((rate Ii]
i++;
A.
B.
C.
D.
34.
show (rate);
show (double []
void
show
);
(double vals []
in file?
A.
B.
in_file.
C.
Open "exam.dat"
as in_file.open;
D.
Open "exam.dat"
open="exam.
dat";
15
TCB2O73
35.
36.
Which of the following C++ statements will read a character from a file
readily connected with fstream object called readme?
A.
ch:readme;
B.
readme.get (ch);
C.
cin((readme((ch
D.
Tuple is (are)
A.
B.
C.
D.
37.
38.
a set of relations.
row(s) of a relation.
a named column of a relation.
Data
Definition
EXCEPT
A.
CREATE
B.
ALTER
C.
DELETE
D.
TRUNCATE
Language(DDL) includes
all
commands below
DROP
B.
INSERT
C.
SELECT
D.
UPDATE
16
TCB2073
ENGINEER-ID
AGE
SAIARY
DEPT NAME
Faheem
223368
24
3 000
Mechanical
Rahmanov
13771,4
30
4 350
Chemical
Mphatabalo
717945
30
4580
Petroleum
39.
TRUNCATE TABLE
A,
B.
C.
D.
40.
delete table
Engineer
will
engineer
engineer
engineer
A.
CREATE TABLE
Engineer
(
B.
CREATE TABLE
Engineer
(
17
TCB2073
C.
CREATE TABLE
Engineer
{
D,
CREATE TABLE
Engineer
(
1B
TCB2O73
SECTION B
[60 Marks]
There are THREE questions in this section. Answer ALL questions.
1.
a.
of students in each
hostel and find the hostel with the highest number of students.
A sample of output is shown in FIGURE Q1. Analyze the output
screen, then write a complete C++ program.
Hame
UILLGE 1
UIILGE 2
UIILGE 3
UILLAGE 4
UILIGE 5
UIILGE 6
HosteI
HLrmher-
of Students
2T
3B
2B
4EO
JE
158
-il;-;ili-ffi;;-;;;;,,,
FIGURE Q1
[18 marks]
b.
[2 marks]
19
TC82073
2.
as shown
in
FIGURE
Q2a:
Petroleum
FIGURE Q2a
Write a program that will read the data from production.dat and
produce the output as in FIGURE Q2b into a file named
Product
Unit
Petrofeum
thousand
Natural
2I19.00
3.27
Coal
Gas
Annual Production
696.2r
FIGURE Q2b
[20 marks]
20
TCB2O73
3.
TABLE Q3a, Q3b and Q3c show the tables in a database, VehicleDB.
TABLE Q3a: Customer Table
CustomerlD
Name
Address
Phone Number
101
Simon Cowell
3 Jalan Mentimun
054568974
1102
Katijah Ahmad
6 Meru Height
058974569
103
Lee Cheng Ee
9 Taman Sentosa
041235698
GolorlD
Feature
vA2
2013
B1
Automatic
VM2
2013
R1
Manual
SA2
2013
W1
Automatic
SA1
2012
B1
Manual
TransactionlD
ModellD
Buyer
Quantity
41234
vA2
1101
41234
VM2
1101
80987
SA2
1102
c9834
SA1
103
a.
Customer, Vehicle
nd
[3 marks]
21
TCB2O73
b.
Write the SQL query that will insert new customer with
the following information into the Customer table.
GustomerlD
Address
Name
Phone
Number
1104
Rajukumar 12 Jalan
047894563
Selesa
[4 marks]
c.
Write the SQL query that will look for vehicle with
manual feature, manufactured in year 2013 and 2012.
[3 marks]
d.
Write the SQL query that will display the order details of
order
Table
as below:
TransactionlD
ModellD
Buyer
Quantity
41234
vA2
1101
41234
VM2
1101
80987
SA2
1102
c9834
SA1
1103
[4 marks]
Show the result for the following SQL query:
SELECT PhoneNumber,
Customer, Order
Buyer, CustomerlD
WHERE
FROM
Buyer:CustomerID
[2 marks]
22
TCB2O73
g.
.END OF PAPER.
23