Question 4
AQA Computer Science June 2022 Paper 1A (8525/1A)GCSE3 marks
On the specification
- 4.1
- 3.1 Fundamentals of algorithms
- 4.2
- 3.1 Fundamentals of algorithms
Question text
4 The two C# programs in Figure 5 output the value that is equivalent to adding box together the integers between 1 and an integer entered by the user. For example, if the user entered the integer 5, both programs would output 15 Figure 5 Program A Console.Write("Enter a number: "); int num = Convert.ToInt32(Console.ReadLine()); int total = 0; for (int i = 1; i < num + 1; i++) { total = total + i; } Console.WriteLine(total); Program B Console.Write("Enter a number: "); int num1 = Convert.ToInt32(Console.ReadLine()); int num2 = num1 + 1; num2 = num1 * num2; num2 = num2 / 2; Console.WriteLine(num2); 4.1 Shade one lozenge to indicate which of the statements is true about the programs in Figure 5. [1 mark] A Both programs are equally efficient. B Program A is more efficient than Program B. C Program B is more efficient than Program A. 4.2 Justify your answer for Question 04.1. [2 marks]