2022 New Spec

From TRCCompSci - AQA Computer Science
Revision as of 08:50, 2 February 2023 by Admin (talk | contribs)
Jump to: navigation, search

Figure 3 shows an algorithm represented using pseudo-code.

Figure 3

C ← 0
D ← 0
S ← 0
T ← 0
WHILE C < 3 AND D < 3
 T ← T + 1
 N1 ← generate random integer between 1 and 6 inclusive
 N2 ← generate random integer between 1 and 6 inclusive
 OUTPUT N1, N2
 S ← S + N1 + N2
 IF N1 = 6 OR N2 = 6 THEN
 C ← C + 1
 ENDIF
 IF N1 = N2 THEN
 D ← D + 1
 ENDIF
ENDWHILE
A ← S DIV (T * 2)
OUTPUT C, D, A

The DIV operator calculates the whole number part resulting from an integer division, for example, 10 DIV 3 = 3.

Table 4 lists the DIV operators for each of the available programming languages. You should refer to the row for your programming language.

Table 4

Programming Language Div
C# /
Java /
Pascal Div
Python //
VB \