Difference between revisions of "2017 New Spec"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "==Question 3== The algorithm represented using pseudo-code in Figure 5 describes a method to find the greatest common factor (GCF) of two whole numbers (integers) entered by t...")
 
(No difference)

Latest revision as of 09:15, 22 November 2017

Question 3

The algorithm represented using pseudo-code in Figure 5 describes a method to find the greatest common factor (GCF) of two whole numbers (integers) entered by the user.

Figure 5

OUTPUT "Enter a whole number: "
INPUT Number1
OUTPUT "Enter another whole number: "
INPUT Number2
Temp1 ← Number1
Temp2 ← Number2
WHILE Temp1 ≠ Temp2
 IF Temp1 > Temp2 THEN
 Temp1 ← Temp1 – Temp2
 ELSE
 Temp2 ← Temp2 – Temp1
 ENDIF
ENDWHILE
Result ← Temp1
OUTPUT Result, " is GCF of ", Number1, " and ", Number2

What you need to do:

Task 1

Write a program to implement the algorithm in Figure 5.

Task 2

Test the program by showing the result of entering 12 and then 39

Evidence that you need to provide

Include the following in your Electronic Answer Document:

Your PROGRAM SOURCE CODE for Task 1. [6 marks]

SCREEN CAPTURE(S) showing the test described in Task 2. [1 mark]