You are on page 1of 3

Section A

Answer ALL questions


1. Which of the following algorithms satisfies the requirement of asking the user to input two
numbers, calculating the average and displaying the result?
(A) display ‘Enter two numbers’
input a , b
c = (a + b)/2
display c
(B) input a, b
c = (a + b) / 2
display c
(C) display 'Enter two numbers'
input a, b
c=a+b/2
display c'
(D) irtput a, b
c =. a + b / 2
display c
2. The variables h and s are assigned the following values, h = 4.and s = 3 * h. Display h + s *2
will show:
(A) 28
(B) 30
(C) 32
(D) 38

3. Which of the following identifiers is NOT a valid variable name?


(A) avg
(B) totalCost
(C) 9Count
(D) NumCount

4. The term used to describe a memory location whose value changes during program execution
is
(A) Constant
(B) volatile
(C) variable
(D) Dynamic
5. The MOST appropriate data type for storing the amount of interest earned on a sum of
money is
(A) real
(B) char
(C) string
(D) integer

6. Which line contains a processing statement in the following algorithm?


PRINT ("Enter price: ") (1 )
READ price (2)
Vat  price * 15% (3)
PRINT vat (4)
(A) 1
(B) 2
(C) 3
(D) 4

7. A trace table is used for:


(A) testing an algorithm
(B) declaring an array
(C) coding an algorithm
(D) representing an algorithm
Section B
Answer ALL questions
1. (A) Explain the difference in the execution of the TWO lines of code written below:
(i) Line 1: If MARK > 50 Then print “Good”
(ii) Line 2: If MARK >= 50 Then print “Day”

(C) The number 50 was the value for MARK.


(i) State the line number corresponding to the above code that would print a result.
(ii) Write the result that would be printed.

2. The pseudocode/algorithm below contains errors, correct the errors by rewrite the code.
value1, value2: integer;
Minimum: real;
value1 = 30;
value2 = 25.9;
IF (value1 > value2)
THEN read(‘MinA is’, value2)
ELSE writeln(‘MinB is’, value2);

3. Write a pseudocode algorithm to read two numbers and find their sum and product.

4. Write a pseudocode algorithm to read values into A and B and subtract the larger number
from the smaller.

5. Write a pseudocode algorithm to read an integer value for MARK and print the appropriate
grade based on the following:
Mark Grade
80 or more A
Less than 80 but 55 or more B
Less than 55 but 45 or more C
Less than 45 F1

You might also like