Professional Documents
Culture Documents
Class: DP1 A
Date: 18/10/23
(May 2017)
November 2019
November 2019
Nov 2018
November 2019
Teacher’s
13*16+9= 217
A=5
B=A
C=6
A=C+1
output ( B )
B=B-1
A = C + A*2 – B // 6 + 7*2 - 4
output ( A )
5, 16
A=4
B=0
C=3
B = B +1 //1
C = C -1 //2
A = B //1
B = B +1 //2
if ( B = C ) then //true
C = C +1
else
output (C)
B = B +1
end if
1, 2
C) Third algorithm [2 marks]
A=1
B = 10
C=5
if ( A + C = 7 ) then //false
output B
C=C+2
else
output C // 5
C = C + 3 //8
end if
B=5
else if (B + A) = 6 then
C = 10
if ( A + C = 11 ) then
output C
else
B=B+C
output B
end if
B = 20
else
C = 20
output A
B = 30
end if
A = A + B + C // 1 + 5 + 8
output A // 14
5,14
3) Create a trace table (headers with the name of the variables) of this algorithm [4
marks]
A B C D
A=1
1 20 10 5
B = 20 1 20 50 5
0 20 50 5
C = 10 0 20 50 2
D=5 0 20 50 2
0 20 50 54
C=5*C 54 20 50 54
A = C mod D
D = C div B
B=B+A
D=D*D+C
A = D div (A +1)
4)
a. Looking at this algorithm state the purpose of the variables P Q and R [1 mark]
N = 354
P = N div 100
R = N mod 10
b. Using the same algorithm as in 4)a) state what would be the values of P, Q and
R if the value N is 687 [1 mark]