Test Februari 2022-1
Test Februari 2022-1
Test Februari 2022-1
UNIVERSITI TEKNOLOGI
MARA FINAL
EXAMINATION
INSTRUCTIONS TO CANDIDATES
1. This question paper consists of three (3) parts: PART A (10 Questions)
PART B (4 Questions)
PART C (1 Question)
A. sequential
B. selection
C. repetition
D. decision
if (x = ! 0) //Line 1
cout << "High";
else //Line 3
cout << "Low";
4. Identify the number of times the body of loop being executed in the following nested
loop.
A. 20
B. 25
C. 30
D. 35
5. Which of the following is the CORRECT syntax of a for loop?
⑤>
int input, count = 0;
count
50
cin >> input;
while (input != -1)
{
if (input > 50)
:
count++;
Choose the correct output if the user enters the following data:
42 88 13 10 91 89 90 54
-1
A. 5
© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
B. 6
C. 8
D. 9
7. Select the FALSE statement about a for loop structure.
cos(x)
exp(x)
fabs(x)
abs(x)
A. User-defined function
B. Pre-defined function
C. void function
D. Value returning function
A. guess(6, 9);
B. guess(x, 9);
C. guess(x, x);
D. guess(x, y);
if (no1 != no2) 17
{
if (no2 == 13) 28
cout<<no2;
else
{
n01, n02
cout<<no1+no2<<endl;
cout<<no1*2;
}
}
cout<<"\nno1, no2";
(3 marks)
b) There are a few errors in the given code segment written in C++. Identify the errors, and
write the corrected code segment.
(2 marks)
QUESTION 2
The fee rates per group for the competition are shown in
table given below:
Condition
Average s Vouche
weekly r
Purchase Points
Successfully Purchases made
rated a from
product Preferred
sellers
Less than 500 Y/N Y/N 0
More than or equal to
500 and less than 1000 Y Y 400
More than or equal to Y Y/N 900
1000
QUESTION 3
Write a main program that accepts a positive integer number from the user and displays all
the factors of that number. The program must also be able to count how many factors the
number has. Factors are the values that the number is divisible by without any remainder.
QUESTION 4
2
(3 marks)
b) Using the above function in (a), write a main program that requires user to input value
of x and y, then calculate and display area of the shaded region in given figure below.
(7 marks)
Categor Fee
y (RM)
Child (4-12 years old) 23
Adult (13-59 years old) 33
Senior citizen (60 years and above) 20