You are on page 1of 5

50

CSC126
FUNDAMENTALS OF ALGORITHMS
&
COMPUTER PROBLEM SOLVING

QUIZ 1

Name :
Student ID :
Group :

INSTRUCTIONS TO CANDIDATES:
1. This question paper consists of four (4) parts:
 Part A (10 Questions) – 10 Marks
 Part B (5 Questions) – 10 Marks
 Part C (5 Questions) – 10 Marks
 Part D (1 Question) – 20 Marks
2. Answer ALL questions

SELF-DECLARATION:
1. I know that plagiarism is wrong. Plagiarism is to use another’s work and pretended that is
in one’s own.
2. This assignment/project/test/quiz/final is my own work.
3. I have not involved, and will not allow, anyone to copy my work with the intention of
passing it off as their own work.
4. I acknowledge that copying someone else’s work (or part of it) is wrong and declare that
my assignment/project/test/quiz/final assessment is my own work.
Part A (10 marks)

Answer the questions below.

1. Select the language that uses mnemonic codes, abbreviations that easy to remember.
A. High level language
B. Assembly language
C. Machine language
D. English language

2. Identify the type of error in a source code that may produce an incorrect output of the
program.
A. syntax error
B. logic error
C. systematic error
D. run-time error

3. Initialization of variables can be written as follows EXCEPT:


A. double x= 12.5;
B. char x = 'd';
C. z = 13;
D. 13 = int y;

4. Choose of the following that is NOT a correct data type for a variable.
A. char
B. double
C. int
D. real

5. Identify the CORRECT C++ statement.


A. cout << " Passing " << endl;
B. cout << "Passing"; << " F a i l i n g " << endl;
C. cout << "Passing" end;
D. cout >> "Passing";

6. Select the type of code that is editable.


A. Object
B. Executable
C. Library
D. Source
7. The purpose of COMMENTS in C++ is as follows EXCEPT:
A. Allow readability and understanding of a computer
B. Use to document a program
C. Causes action to be performed when a program is executed
D. None of the above

8. Determine the main purpose of testing during fourth phase in Program Development Life
Cycle (PDLC).
A. It is to detect and remove errors
B. It is to implement the developed application system
C. It is to write a program based on algorithm and analysis done earlier
D. It is to identify and analyze the problem

9. Identify the INVALID variable name.


A. newtax
B. prod_A
C. sum.of
D. t1234

10. Select the term used for the rule of any programming languages
A. library
B. syntax
C. semantics
D. structure

PART B (10 MARKS)

Q1: Write an assignment statement to implement each of the following equation in C++
programming language.

4+3𝑥 10−𝑥
a) 𝑍= +
6−𝑦 𝑦+2

1
b) 𝑆 = 𝑆 + 𝑉𝑡 + 𝑔𝑡 4
2

c) 𝑌 = √𝑆𝑥 3 + 𝑎𝑏 2

[6 marks]
Q2: Determine the output of the following C++ statements. You have to start at the beginning
and the statements are executed in sequence.
a)

b)

[4 marks]

PART C (10 MARKS)

Write a C++ statement to do the following tasks:

a) Add 5 to variable named num and stores the result in variable named total

b) Assign value ‘P’ to variable status

c) Print the message “C++ for Beginners” with each word of the message separated on a
separate line

d) Declare three integer variables. Assign 10 to the first variable

e) A floating-point variable named initial with value 100


PART D (20 MARKS)

Create a program to determine the surface area and volume of a cylinder. First, you need to write
the pseudo-code and draw a flowchart. You will write a complete C++ program which it is to
accept the radius and height of the cylinder from a user. Later, the program will display the
surface area and volume of a cylinder. The formula of volume and surface area of a cylinder
with its radius and height is given below:

Volume =  x r x r x h, where  is 3.14159


Surface_Area = 2 x  x r x (r + h)

You might also like