Question 1

AQA Computer Science June 2022 Paper 1C (8525/1C)GCSE6 marks

On the specification

1.1
3.2 Programming
1.2
3.1 Fundamentals of algorithms3.2 Programming
1.3
3.2 Programming
1.4
3.2 Programming
1.5
3.2 Programming
1.6
3.2 Programming
Question text

1 An algorithm, that uses the modulus operator, has been represented using pseudo-code in Figure 1. • Line numbers are included but are not part of the algorithm. Figure 1 1 i  USERINPUT 2 IF i MOD 2 = 0 THEN 3 OUTPUT i * i 4 ELSE 5 OUTPUT i 6 ENDIF The modulus operator is used to calculate the remainder after dividing one integer by another. For example: • 14 MOD 3 evaluates to 2 • 24 MOD 5 evaluates to 4 1.1 Shade one lozenge that shows the line number where selection is first used in the algorithm in Figure 1. [1 mark] A Line number 1 B Line number 2 C Line number 3 D Line number 4 1.2 box Shade one lozenge that shows the output from the algorithm in Figure 1 when the user input is 4 [1 mark] A 0 B 2 C 4 D 8 E 16 1.3 Shade one lozenge that shows the line number where assignment is first used in the algorithm in Figure 1. [1 mark] A Line number 1 B Line number 2 C Line number 3 D Line number 4 1.4 Shade one lozenge that shows the line number that contains a relational operator in the algorithm in Figure 1. [1 mark] A Line number 1 B Line number 2 C Line number 3 D Line number 4 Figure 1 has been included again below. Figure 1 1 i  USERINPUT 2 IF i MOD 2 = 0 THEN 3 OUTPUT i * i 4 ELSE 5 OUTPUT i 6 ENDIF 1.5 Shade one lozenge to show which of the following is a true statement about the algorithm in Figure 1. [1 mark] A This algorithm uses a Boolean operator. B This algorithm uses a named constant. C This algorithm uses iteration. D This algorithm uses the multiplication operator. 1.6 Figure 2 shows an implementation of the algorithm in Figure 1 using the VB.Net programming language. • Line numbers are included but are not part of the program. Figure 2 1 Console.Write("Enter a number: ") 2 Dim i As Integer = Console.ReadLine() 3 If i Mod 2 = 0 Then 4 Console.WriteLine(i * i) 5 Else 6 Console.WriteLine(i) 7 End If The program in Figure 2 needs to be changed so that it repeats five times using definite (count controlled) iteration. Shade one lozenge next to the program that does this correctly. [1 mark] Dim x As Integer = 1 While x <> 6 Console.Write("Enter a number: ") Dim i As Integer = Console.ReadLine() If i Mod 2 = 0 Then A Console.WriteLine(i * i) Else Console.WriteLine(i) End If x = x + 1 End While Dim x As Integer = 6 While x <> 0 Console.Write("Enter a number: ") Dim i As Integer = Console.ReadLine() If i Mod 2 = 0 Then B Console.WriteLine(i * i) Else Console.WriteLine(i) End If x = x - 1 End While For x As Integer = 0 To 4 Console.Write("Enter a number: ") Dim i As Integer = Console.ReadLine() If i Mod 2 = 0 Then C Console.WriteLine(i * i) Else Console.WriteLine(i) End If Next For x As Integer = 0 To 5 Console.Write("Enter a number: ") Dim i As Integer = Console.ReadLine() If i Mod 2 = 0 Then D Console.WriteLine(i * i) Else Console.WriteLine(i) End If Next 6