Sei sulla pagina 1di 12

Chapter 13 Programming Languages Question Bank

Chapter 13 Programming Languages


Multiple Choice Questions

(U01C13L01Q001)
Which of the following is the feature of a procedural language?
A. It allows users to write programs that only state the query to be solved.
B. Each instruction consists of an operation code and an operand.
C. It must clearly shows the procedures of carrying out algorithms.
D. It uses mnemonics to make an instruction to be more meaningful to human.
Answer
C

(U01C13L01Q002)
Which of the following is the feature of a non-procedural language?
A. It allows users to write programs that only state the query to be solved.
B. Each instruction consists of an operation code and an operand.
C. It must clearly shows the procedures of carrying out algorithms.
D. It uses mnemonics to make an instruction to be more meaningful to human.
Answer
A

(U01C13L01Q003)
Which of the following is a low level programming language?
A. C language
B. Assembly language
C. Pascal
D. Basic
Answer
B

(U01C13L01Q004)
Machine language expresses instructions in
A. binary codes.
B. mnemonics.
C. operand.
D. natural language.
Answer
Computer & Information Technology for HKCEE 1 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

Computer & Information Technology for HKCEE 2 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

(U01C13L01Q005)
Assembly language uses _______________ to represent operation codes.
A. keywords
B. command
C. mnemonics
D. operand
Answer
C

(U01C13L01Q006)
An instruction of machine language can be divided into two parts. What are they?
A. command and operator
B. keyword and operand
C. word and number
D. operation code and operand
Answer
D

(U01C13L01Q007)
Visual Basic is considered as a/an
A. assembly language.
B. machine language.
C. high level language.
D. low level language.
Answer
C

(U01C13L01Q008)
Which of the following translators will NOT produce a machine code?
(1) interpreter
(2) compiler
(3) assembler
A. (1) only
B. (2) only
C. (2) and (3) only
D. (1), (2) and (3)
Answer
A
Computer & Information Technology for HKCEE 3 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

(U01C13L01Q009)
Which of the following translators do / does not require source program when the
program is executed?
(1) interpreter
(2) compiler
(3) assembler
A. (1) only
B. (3) only
C. (2) and (3) only
D. (1), (2) and (3)
Answer
B

(U01C13L01Q010)
Which of the following statements about interpreter is correct?
A. It translates machine language program into high level language program.
B. It executes the program after the program is translated.
C. Object programs are produced after the translation.
D. Translation has to be performed whenever the program is executed.
Answer
D

(U01C13L01Q011)
Pascal
A. is a machine language.
B. is an object-oriented language.
C. needs to be compiled before it is executed.
D. uses binary code to write commands.
Answer
C

Computer & Information Technology for HKCEE 4 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

(U01C13L01Q012)
Compiler
A. converts flowchart into pseudo code.
B. converts pseudocode into object program.
C. coverts source program into object program.
D. converts object program into source program.
Answer
C

(U01C13L01Q013)
Which of the following statements about low-level programming language is correct?
A. Low-level programming language is designed for beginners of learning
programming.
B. Low-level programming language is usually more concise than high-level
language.
C. Low-level programming language is usually faster than high-level language
when it is executed.
D. Programming using low-level language usually needs shorter time than using
high-level language.
Answer
C

(U01C13L01Q014)
Interpreting a program
A. will create source program.
B. will not produce object code.
C. often happens to first generation language.
D. needs shorter time than compiling a program.
Answer
B

Computer & Information Technology for HKCEE 5 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

(U01C13L01Q015)
Which of the following statements about computer language is/are correct?
(1) The first generation language uses binary codes to form commands.
(2) SQL is a stepwise language.
(3) Pseudocode is one type of high-level language.
A. (1) only
B. (2) only
C. (2) and (3) only
D. (1), (2) and (3)
Answer
A

Computer & Information Technology for HKCEE 6 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

Conventional Questions

(U01C13L02Q001)
Terry is writing a program to calculate the sum 1 + 2 + 3 + .... +99 + 100.
Before writing the program, Terry sketches the flowchart as below:

BEGIN

N = 1, M = 0

True
M=M+N

N=N+1

N < 100 ?

False

Print M

(a) (i) Point out FOUR mistakes of this flowchart and state how they can be
corrected. (4 marks)
(ii) Why is it necessary to sketch the flowchart before writing a program?
(2 marks)
Terry starts writing the program after he has corrected the mistakes of the flowchart.
He wants to use high-level language to write the program.
(b) (i) Why Terry uses high-level language to write the program? State TWO
reasons. (2 marks)
(ii) Suggest a high-level language to Terry for writing the program. (1 mark)
After writing the program, Terry starts compiling it.
(c) (i) What is the purpose of compilation? (2 marks)
(ii) After compiling the program successfully, what should Terry do next?
(1 mark)

Computer & Information Technology for HKCEE 7 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

Answers
(a) (i) “N < 100” should be changed to “N ≤ 100”. (1)
Add “END” symbol to the bottom end of the flowchart. (1)
The box for “Print M” should be parallelogram. (1)
Add arrows to the flow lines. (1)
(ii) Flowchart belongs to the step of designing algorithm while writing program
is a step of developing solutions. (1) One should design the algorithm
before executing it. (1)
(b) (i) Commands used are more English-like than low-level language. /
It is problem-based and designed for solving specific problem. /
It is easier to learn than machine language. /
One command can replace many machine language instructions.
(Any 2 × 1)
(ii) Pascal / C / C++ / BASIC / Java / COBOL (Any 1× 1)
(c) (i) Convert high-level language into machine language program. (2)
(ii) testing / debugging (1)

Computer & Information Technology for HKCEE 8 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

(U01C13L02Q002)
Given an assembly language program below:
INP 1010
ADD 1100
STA 1110
STP
The table below shows the corresponding operation codes of the mnemonics.
Mnemonics Operation Code
ADD 0001
INP 0010
STA 0011
STP 0100
(a) (i) Translate the assembly language program into a machine language program.
(2 marks)
(ii) Write down all the operands of the machine language program in (a). (1
mark)
Mary uses a high level programming language to write a program and saves it as file
‘PROGA’. Before the program can be executed, it must be translated to and saved as a
file called ‘PROGB’.
(b) (i) Why ‘PROGA’ must be translated to ‘PROGB’ before it can be executed?
(1 mark)
(ii) What program is used to translate ‘PROGA’ to ‘PROGB’? (1 mark)
(iii) Which files are called source program and object program correspondingly?
(2 marks)
(iv) 「What programming language is ‘PROGB’ written in? (1 mark)
Answer
(a) (i) 00101010
00011100
00111110
0100 (2)
(ii) 1010
1100
1110 (1)
(b) (i) It is because computers can only understand machine language, program
written in other languages must be translated into machine language
programs before they can be executed. (1)
(ii) Compiler (1)
(iii) The source program is ‘PROGA’, (1) the object program is ‘PROGB’. (1)
(iv) Machine language (1)
Computer & Information Technology for HKCEE 9 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

(U01C13L02Q003)
A machine language instruction consists of 4-bit operation code and 4-bit operand. A
machine language program is given below:
0001 0010
0000 1100
0100 0101
0011 1101
(a) (i) Write down all the operation codes of the machine language program.
(1 mark)
(ii) Write down all the operands of the machine language program. (1 mark)
The table below shows the corresponding operation codes of the mnemonics.
Mnemonics Operation Code
ADD 0000
INP 0001
LDA 0010
OUT 0011
STA 0100
STP 0101

(b) Represent the machine language instructions with assembly language


instructions. (1 mark)
Peter designs a Telephone Directory. He employs the technique of stepwise
refinement to analyse the problem. Peter breaks down the problem into several sub-
tasks and draws the following block diagram for the problem.

T e le p h o n e D ire c to ry

A d d re c o rd D e le te re c o rd S o rt re c o rd S e a rc h re c o rd D is p la y re c o rd

S e a rc h re c o rd S e a rc h re c o rd
by N A M E by TELEPH O N E

(c) Briefly describe the term ‘stepwise refinement’ and give ONE advantage of this
technique. (2 marks)
(d) Briefly describe ONE advantage of drawing a block diagram for the problem.
(1 mark)
Peter uses an assembly language to write his program and saves it as a file ‘FILEA’.
Before the program can be executed, it must be translated to and saved as a file called
‘FILEB’.
(e) (i) What program does Peter use to translate ‘FILEA’ to ‘FILEB’? (1 mark)
(ii) Which file (‘FILEA’ or ‘FILEB’) can be executed directly by a computer?
Computer & Information Technology for HKCEE 10 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

Why? (2 marks)
(iii) Peter deletes ‘FILEA’ accidentally. Can ‘FILEB’ be executed without
‘FILEA’? Why? (2 marks)
Peter finds that programs written in assembly language have some disadvantages.
(f) Give ONE disadvantages of using assembly language to write programs. (1 mark)
Answers
(a) (i) 0001
0000
0100
0011 (1)
(ii) 0010
1100
0101
1101 (1)
(b) INP 0010
ADD 1100
STA 0101
OUT 1101 (1)
(c) Stepwise refinement is a process of breaking down a problem into a number of
modules in a series of steps. (1) It is easier to tackle several smaller problems
one at a time than a single complicated problem. (1)
(d) A block diagram can be used to show the modular structure of a problem and
the relationship between modules. (1)
(e) (i) assembler (1)
(ii) FILEB. (1) It is because a computer can execute program written in
machine language only. (1)
(iii) Yes. (1) ‘FILEB’ is the version of ‘FILEA’ written in machine language. A
computer can execute the machine language program directly. (1)
(f) Difficult to write / Difficult to understand or trace error / Machine dependent
(Any reasonable answers) (Any 1 × 1)

Computer & Information Technology for HKCEE 11 © Pearson Education Asia Limited 2004
(Core Module)
Chapter 13 Programming Languages Question Bank

(U01C13L02Q004)
The diagram below shows the functions of different translators.

A Assembler B
whole
program

Compiler
D Execution
C whole
program

Y
E one
instruction
at a time
Program A is translated to program B by an assembler.
Program C is translated to program D by a compiler.
Program E is translated by a translator Y.
(a) Identify all source programs. (3 marks)
(b) Identify all object programs. (2 marks)
(c) Identify all programs written in machine language. (2 marks)
(d) Identify all low level language programs. (3 marks)
(e) Identify all high level language programs. (2 marks)
(f) What kind of translator is Y? (1 mark)
Answers
(a) Programs A, C and E (3)
(b) Programs B and D (2)
(c) Programs B and D (2)
(d) Programs A, B and D (3)
(e) Programs C and E (2)
(f) Interpreter (1)

Computer & Information Technology for HKCEE 12 © Pearson Education Asia Limited 2004
(Core Module)

Potrebbero piacerti anche