Sie sind auf Seite 1von 10

Chapter 4 Writing Programs Question Bank

Chapter 4 Writing Programs


Multiple Choice Questions

(U03C04L01Q001)
Which of the following is NOT a reserved word?
A. end
B. div
C. array
D. copy
Answer
D

(U03C04L01Q002)
Which of the following identifiers are VALID?
(1) FirstExamination
(2) Test2
(3) 3rdExamination
A. (1) and (2) only
B. (1) and (3) only
C. (2) and (3) only
D. (1), (2) and (3)
Answer
A

(U03C04L01Q003)
Which of the following is NOT a part of Pascal program structure?
A. program heading
B. declaration part
C. program body
D. program ending
Answer
D

Computer & Information Technology for HKCEE 1 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

(U03C04L01Q004)
Which of the following pair of symbols is used to enclose comments in Pascal?
A. (* ... *)
B. (…)
C. < ... >
D. *... *
Answer
A

(U03C04L01Q005)
Which of the following is a valid identifier for holding the class number of a student?
A. ClassNumber
B. Class Number
C. Class-Number
D. Class@Number
Answer
A

(U03C04L01Q006)
Which of the following statements can declare a constant Rate which has a value equal to 5%?
A. const Rate = 5%;
B. const Rate = 0.05;
C. const Rate = 5;
D. const Rate = (5 / 100)%;
Answer
B

(U03C04L01Q007)
Which of the following statements can declare a string variable Student?
A. const Student = string;
B. const Student : string;
C. var Student = string;
D. var Student : string;
Answer
D

Computer & Information Technology for HKCEE 2 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

(U03C04L01Q008)
Which data type is the most suitable for holding the student number 0041123?
A. integer
B. real
C. string
D. Boolean
Answer
C

(U03C04L01Q009)
Which of the following is NOT a data type in Pascal?
A. real
B. char
C. Boolean
D. queue
Answer
D

(U03C04L01Q010)
Which of the following data type has only two possible values?
A. real
B. char
C. Boolean
D. data
Answer
C

(U03C04L01Q011)
What is the output of the following Pascal statement?
write (1 + 2 : 1 + 2)
A. 1 + 2 : 1 + 2
B. 3 : 3
C. 3
D. 3
Answer
D

Computer & Information Technology for HKCEE 3 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

(U03C04L01Q012)
What is the output of the following Pascal statement?
write (-76.54 : 9 : 3)
A. –76.54
B. –76.540
C. –76.540
D. –76.54000
Answer
C

(U03C04L01Q013)
What is the output of the following Pascal statement?
write (1 + 3 = 1 + 3)
A. 4 = 4
B. 4
C. TRUE
D. FALSE
Answer
C

(U03C04L01Q014)
Which of the following expressions and the corresponding results is/are correct?
Expressions Results
(1) 28/5 5.6
(2) 28 mod 5 5
(3) 28 div 5 3

A. (1) only
B. (1) and (2) only
C. (2) and (3) only
D. None of the above
Answer
A

Computer & Information Technology for HKCEE 4 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

(U03C04L01Q015)
Which of the following expressions will return results of integer data type?
(1) abs(-15)
(2) round(8.4)
(3) 11 mod 5
A. (1) and (2) only
B. (1) and (3) only
C. (2) and (3) only
D. (1), (2) and (3)
Answer
D

(U03C04L01Q016)
What is the result of the following expression?
Sqrt(abs(-144))
A. –12
B. 12
C. 144
D. Error
Answer
B

(U03C04L01Q017)
What is the result of the following expression?
98.76 – trunc(98.76)
A. –0.76
B. 0
C. 0.76
D. 1
Answer
A

Computer & Information Technology for HKCEE 5 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

(U03C04L01Q018)
Suppose variable x has a value 1234.56. Which of the following statement(s) return(s) value 0.56?
(1) x - trunc(x);
(2) trunc(x) - x;
(3) round(x) – trunc(x);
A. (1) only
B. (2) only
C. (3) only
D. (1) and (2) only
Answer
A

Computer & Information Technology for HKCEE 6 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

Conventional Questions

(U03C04L02Q001)
Consider the following program.
program Mean;
var A, B : integer;
begin
write(‘Enter 2 integers: ’);
readln(A, B);
writeln(‘The mean of A and B is ’, (A + B) / 2:0:2)
end.
List all the
(a) reserved words,
(b) identifiers.
(10 marks)
Answers
(a) program, var, begin, end
(b) A, B, integer, write, readln, writeln

(U03C04L02Q002)
Complete the following program by filling suitable reserved words or identifiers in the blanks.
_(a)_ Exercise;
_(b)_ Name = ‘Peter’;
_(c)_ Age : (d)_;
_(e)_
Age := 16.5 ;
writeln(Name, ‘ is ’, Age, ‘ years old.’)
_(f)_. (6 marks)
Answers
(a) program
(b) const
(c) var
(d) real
(e) begin
(f) end

Computer & Information Technology for HKCEE 7 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

(U03C04L02Q003)
State a data type that is the most suitable for the following data.

Data Example
(a) Height in metre 1.65
(b) Email address info@longman.com
(c) Sex M
(d) Number of students in a class 40
(e) An indicator for fee remission TRUE
(5 marks)
Answers
(a) real
(b) string
(c) char
(d) integer
(e) Boolean

(U03C04L02Q004)
State whether each of the following words is a valid or an invalid identifier. Explain if it is invalid.
(a) Z
(b) @
(c) Class Number
(d) Class-Number
(e) Number2
(f) 2Names
(g) End (7 marks)
Answers
(a) Valid.
(b) Invalid. Symbol ‘@’ is not allowed.
(c) Invalid. Blank space is not allowed.
(d) Invalid. Symbol ‘-‘ is not allowed.
(e) Valid.
(f) Invalid. An identifier must start with a letter.
(g) Invalid. Reserved words cannot be used as identifiers.

Computer & Information Technology for HKCEE 8 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

(U03C04L02Q005)
(a) Write the program heading for a program with the name BookRecord.
(b) Write the constant declaration of the program according to the following table.

Name of Constant Data Type Value


School string ‘ABC School’
NumberOfStudent integer 1024

(c) Write the declaration part of the program according to the following table.

Name of Variable Data Type Meaning


Book string Book title
Price real Price of the book
NumOfPage integer Number of pages
Reference Boolean Indicator for reference books
NameList array of string Name list of 45 students
(8 marks)
Answers
(a) program BookRecord;
(b) const
School = ‘ABC School’;
NumOfStudent = 1024;
(c) var
Book : string;
Price : real;
NumOfPage : integer;
Reference : Boolean;
NameList : array [1..45] of string;

Computer & Information Technology for HKCEE 9 © Pearson Education Asia Limited 2004
(Module A2)
Chapter 4 Writing Programs Question Bank

(U03C04L02Q006)
What are the values stored in variables x, y and z after executing the following program segments?
(a) x := 2;
y := x + 4;
x := x + y;
(b) x := 10;
y := 1
x := x + 1;
x := x + 2;
y := x - y;
(c) x := 10;
y := trunc(sqrt(x));
z := x + y;
(d) x := -5;
y := -x;
z := abs(x - y); (10 marks)
Answers
(a) x = 8, y = 6
(b) x = 13, y = 12
(c) x = 10, y = 3, z = 13
(d) x = -5, y = 5, z = 10

Computer & Information Technology for HKCEE 10 © Pearson Education Asia Limited 2004
(Module A2)

Das könnte Ihnen auch gefallen