Answer Scheme Quiz CSC126 - Okt2021
Answer Scheme Quiz CSC126 - Okt2021
Total Marks: 30
Instructions to Students:
• you are NOT ALLOWED to use the computer during the assessment, except for
reading the question paper
• you are required to answer all questions in handwriting (typing is NOT allowed).
• after you have finished, take photos of your answer and convert to ONE PDF file.
• share your PDF File to Google Classroom.
• answers must be sent within 15 minutes upon completion of the answering
session. The answer document will not be accepted if it is sent late. Inform
your lecturer if you have network problems
• you are reminded to be honest and to NOT share your answers with other
students.
Section A (4 marks)
a. algorithms are written for humans but programs are written for a
computer.
b. the language that is used to write algorithms are usually informal
languages, but programs are written in programming languages
c. algorithms only have one instruction, but programs can have many
instructions
d. mathematical calculations cannot be done in an algorithm, like a
computer program
a. analysis phase
b. design phase
c. implementation phase
d. testing phase
1|Page
3. These are good characteristics of computer programs, EXCEPT
num = x / num * 5;
a. 0.24
b. 7.2
c. 7
d. 5
Question 1
𝐴𝐵 + 𝐶
𝐷 √𝐸 − 𝐹
Answer:
(pow(A,B) + C) / (D * sqrt(E – F))
2.5 marks
2|Page
Question 2
BEGIN
input price,
quantity,
commission rate
calculate
commission = price x
quantity x commission rate
output
commission
END
5 marks
3|Page
#include <iostream> 0.5 marks
using namespace std;
int main()
{
double price, commRate, commission; 1 mark
int quantity;
4|Page
Question 3
data1 = 95;
data2 = 120;
cout<<”First data: “<< data1 <<” second data: “<< data2<<endl;
data1 = data1 + data2;
data2 = data1 * 2;
cout<<”First data: “<< data1 <<” second data: “<< data2<<endl;
data2++;
data1 = data2 % 5;
cout<<”Second data: “<< data2 <<” first data: “<< data1<<endl;
5.5 marks
Answer
Question 4
Tokwan wants to hire a lawn care worker to cut the grass in his yard. The pay rate
is RM2.50 per square meter. The lawn area is the shaded area in this diagram:
You are to help Tokwan by writing a program to calculate the total wages that is
payable to the lawn care worker. The program will the size (area) of the lawn (in
squares metre) and the total wages. (Note: The size of the curved area on the
left side of the house is half of a circle)
5|Page
a. Identify the input data for this problem
2 marks
Answer
Input data:
1. the width and length of the house (s1, s2) 1 mark
2. the width and length of the land 1 mark
Answer
6|Page
c. Write a main function to solve this problem
9 marks
Answer:
int main()
{
const double PAYRATE = 2.5; 0.5 marks
const double PI = 3.14;
cout<<” Enter the width and length of the land: “; 1.5 marks
cin>>width>>length;
7|Page