Question 1

AQA Computer Science June 2022 Paper 1A (8525/1A)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 C# programming language. • Line numbers are included but are not part of the program. Figure 2 1 Console.Write("Enter a number: "); 2 int i = Convert.ToInt32(Console.ReadLine()); 3 if (i % 2 == 0) { 4 Console.WriteLine(i * i); 5 } 6 else { 7 Console.WriteLine(i); 8 } 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] for (int x = 0; x < 5; x++) { Console.Write("Enter a number: "); int i = Convert.ToInt32(Console.ReadLine()); if (i % 2 == 0) { Console.WriteLine(i * i); A } else { Console.WriteLine(i); } } for (int x = 0; x < 6; x++) { Console.Write("Enter a number: "); int i = Convert.ToInt32(Console.ReadLine()); if (i % 2 == 0) { Console.WriteLine(i * i); B } else { Console.WriteLine(i); } } int x = 1; while (x != 6) { Console.Write("Enter a number: "); int i = Convert.ToInt32(Console.ReadLine()); if (i % 2 == 0) { Console.WriteLine(i * i); C } else { Console.WriteLine(i); } x = x + 1; } int x = 6; while (x != 0) { Console.Write("Enter a number: "); int i = Convert.ToInt32(Console.ReadLine()); if (i % 2 == 0) { Console.WriteLine(i * i); D } else { Console.WriteLine(i); } x = x - 1; }