Question 3

AQA Computer Science June 2017 Paper 1AS8 marks

On the specification

3.1
3.1 Fundamentals of programming
3.2
3.3 Systematic approach to problem solving
3.3
3.1 Fundamentals of programming
Question text

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. 3.1 Your PROGRAM SOURCE CODE for Task 1. [6 marks] 3.2 SCREEN CAPTURE(S) showing the test described in Task 2. [1 mark] The algorithm copies the values of Number1 and Number2 into Temp1 and Temp2 respectively. 3.3 Explain why the WHILE loop was written using Temp1 and Temp2 instead of Number1 and Number2. [1 mark] You are advised to spend no more than 20 minutes on this section. Enter your answers to Section B in your Electronic Answer Document. You must save this document at regular intervals. These questions refer to the Preliminary Material and the Skeleton Program, but do not require any additional programming. Refer either to the Preliminary Material issued with this question paper or your electronic copy.