Answer Sheet Csc128 Test 1 March2020
Answer Sheet Csc128 Test 1 March2020
INSTRUCTIONS TO CANDIDATES
* PLEASE ANSWER IN THIS ANSWER SHEET THEN SAVE THIS FILE IN PDF FORMAT
* RENAME THIS FILE AS YOURFULLNAME_ANSWER SHEET_CSC128_TEST 1.PDF
* Please fill all this information below.
NAME :
STUDENT ID :
GROUP :
For Examiner’s
Used Only
Q1 /7
Q2 / 10
Q3 /8
Q4 / 10
Q5 / 15
Total / 50
ANSWER:
Start
Set total = 0
Set i=0
While (i < 10 )
Display “ Enter a mark: “
Get mark
Add the mark into total
Add one to i
EndWhile
Average = total / 10
Display “The total mark: “,total
Display “The average : “,Average
End
(5 marks)
ANSWER:
a. Write a program that prompts the user to enter a series of numbers that ends with
zero. The program has to do the following calculation and print the results.
(6 marks)
ANSWER:
b. Write a program using the for loop that will produce the following multiplication
table:
© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 4 CS/MAC-JULY 2020/CSC128/TEST1
1X2=2
2X2=4
3X2=6
4X2=8
5 X 2 = 10
6 X 2 = 12
7 X 2 = 14
8 X 2 = 16
9 X 2 = 18
10 X 2 = 20
(4 marks)
ANSWER:
QUESTION 3 (8 MARKS)
What is the output of the following C++ codes? *Notes : use tracing table*
b. int i = 2;
while (i < 3) {
© Hak Cipta Universiti Teknologi MARA CONFIDENTIAL
CONFIDENTIAL 5 CS/MAC-JULY 2020/CSC128/TEST1
cout<<“hi ”;
i++;
}
cout<<“bye”;)
(2 marks)
ANSWER:
Raub Roadways Bhd. is starting a bus transportation business which offers trips from Raub
to multiple destinations in east coast region. In order to improve their services, Raub
Roadways Bhd. plans to develop an online ticketing system which enable their passengers
to travel with ease. The following table shows the details of each trip:
This program will allow user to input the destination code and quantity of tickets.
This program should display the details of the chosen destination (destination,
departure time, arrival time, ticket price and total price to be paid by the
customer. (Note: Display an error message for any invalid destination code). Write a
complete C++ program based on the given format of input and output as the following
sample output:
ANSWER QUESTION 4:
QUESTION 5
Damai Bayu Resort offers a variety of packages for the wedding auditorium to their
customers. Payments are based on the type of package and the amount of hours spent. An
additional RM50.00 per guest will be charged for meals. The details of the charges for
each package are shown in the following table:
(15 marks)
ANSWER: