DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO
CONFIDENTIAL
CS/OCT 2010/CSC138
5fpg|
UNIVERSITI TEKNOLOGI MARA
FINAL EXAMINATION
COURSE
STRUCTURED PROGRAMMING
COURSE CODE
CSC138
EXAMINATION
OCTOBER 2010
TIME
3 HOURS
INSTRUCTIONS TO CANDIDATES
1.
This question paper consists of three (3) parts : PART A (10 Questions)
PART B ( 4 Questions)
PART C ( 2 Questions)
2.
Answer ALL questions in the Answer Booklet. Start each answer on a new page.
3.
Do not bring any material into the examination room unless permission is given by the
invigilator.
4.
Please check to make sure that this examination pack consists of:
i)
ii)
the Question Paper
an Answer Booklet - provided by the Faculty
DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO
This examination paper consists of 10 printed pages
© Hak Cipta Universiti Teknologi MARA
CONFIDENTIAL
CONFIDENTIAL
2
CS/OCT 2010/CSC138
PART A (20 MARKS)
1. Which of the following stores the number 17 in row 7 of a two-dimensional array?
A.
B.
C.
D.
for
for
for
for
(int
(int
(int
(int
i
i
i
i
=
=
=
=
0;
1;
0;
1;
i
i
i
i
<
<
<
<
max;
max;
max;
max;
i++)
i++)
i++)
i++)
row[5][i]
row[6][i]
row[7][i]
row[7][7]
=
=
=
=
17;
17;
17;
17;
2. Consider the following declaration:
i n t Gama[2][2];
Assuming the initial value for every component in Gama is 1, what is stored in Gama after
the following statement executes?
for
A. 1
1
B. 1
2
C. 1
1
D. 2
2
( i = 0, i < 2 ; i + + )
f o r (J = 0 ; j < 2 ; j + + )
Gama i ] [ j ] = 1 + 2 * j ;
1
1
2
1
3
3
3
3
3. Sales array, int s a l e s [2] [4] = {{13000, 10000, 12000, 800}, {470, 690,
930,520}}. The statement s a l e s [ l ] [3] = s a l e s [1] [2] + 100; will replace the
number
.
A.
B.
C.
D.
690 With 790
loooo with I O I O O
930 With 1030
520 With 620
© Hak Cipta Universiti Teknologi MARA
CONFIDENTIAL
CONFIDENTIAL
3
CS/OCT2010/CSC138
4. The components of a s t r u c t are called
A.
B.
C.
D.
class
struct
array
member
5. The
A.
B.
C.
D.
is used to access a member of a s t r u c t .
Address operator, &
Indirection operator, *
Dot operator, .
Deferencing operator, ->
6. Given the following structure and structure variable declaration:
struct carType {
char brand[20];
char model [20] ;
floa t price;
int year;
} carl, car2;
Which of the following statement is VALID?
A.
B.
C.
D.
strcpy(carType.model, "Persona");
cout
CS/OCT 2010/CSC138
5fpg|
UNIVERSITI TEKNOLOGI MARA
FINAL EXAMINATION
COURSE
STRUCTURED PROGRAMMING
COURSE CODE
CSC138
EXAMINATION
OCTOBER 2010
TIME
3 HOURS
INSTRUCTIONS TO CANDIDATES
1.
This question paper consists of three (3) parts : PART A (10 Questions)
PART B ( 4 Questions)
PART C ( 2 Questions)
2.
Answer ALL questions in the Answer Booklet. Start each answer on a new page.
3.
Do not bring any material into the examination room unless permission is given by the
invigilator.
4.
Please check to make sure that this examination pack consists of:
i)
ii)
the Question Paper
an Answer Booklet - provided by the Faculty
DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO
This examination paper consists of 10 printed pages
© Hak Cipta Universiti Teknologi MARA
CONFIDENTIAL
CONFIDENTIAL
2
CS/OCT 2010/CSC138
PART A (20 MARKS)
1. Which of the following stores the number 17 in row 7 of a two-dimensional array?
A.
B.
C.
D.
for
for
for
for
(int
(int
(int
(int
i
i
i
i
=
=
=
=
0;
1;
0;
1;
i
i
i
i
<
<
<
<
max;
max;
max;
max;
i++)
i++)
i++)
i++)
row[5][i]
row[6][i]
row[7][i]
row[7][7]
=
=
=
=
17;
17;
17;
17;
2. Consider the following declaration:
i n t Gama[2][2];
Assuming the initial value for every component in Gama is 1, what is stored in Gama after
the following statement executes?
for
A. 1
1
B. 1
2
C. 1
1
D. 2
2
( i = 0, i < 2 ; i + + )
f o r (J = 0 ; j < 2 ; j + + )
Gama i ] [ j ] = 1 + 2 * j ;
1
1
2
1
3
3
3
3
3. Sales array, int s a l e s [2] [4] = {{13000, 10000, 12000, 800}, {470, 690,
930,520}}. The statement s a l e s [ l ] [3] = s a l e s [1] [2] + 100; will replace the
number
.
A.
B.
C.
D.
690 With 790
loooo with I O I O O
930 With 1030
520 With 620
© Hak Cipta Universiti Teknologi MARA
CONFIDENTIAL
CONFIDENTIAL
3
CS/OCT2010/CSC138
4. The components of a s t r u c t are called
A.
B.
C.
D.
class
struct
array
member
5. The
A.
B.
C.
D.
is used to access a member of a s t r u c t .
Address operator, &
Indirection operator, *
Dot operator, .
Deferencing operator, ->
6. Given the following structure and structure variable declaration:
struct carType {
char brand[20];
char model [20] ;
floa t price;
int year;
} carl, car2;
Which of the following statement is VALID?
A.
B.
C.
D.
strcpy(carType.model, "Persona");
cout