Question 14
AQA Computer Science Specimen Paper 1C (8525/1C)GCSE1 mark
On the specification
- 3.2 Programming
Question text
14 A programmer has written the VB.Net program in Figure 5 to add up the box numbers between one and five. Figure 5 Dim total As Integer = 0 Dim number As Integer = 0 For number = 1 To 5 total = total + number Next Console.WriteLine(total) The program needs to be changed so that it also multiplies all of the numbers between one and five. Shade one lozenge next to the program that will do what the programmer wants. [1 mark] Dim total As Integer = 0 Dim product As Integer = 1 Dim number As Integer = 0 For number = 1 To 5 A total = total + number product = total * number Next Console.WriteLine(total) Console.WriteLine(product) Dim total As Integer = 0 Dim product As Integer = 1 Dim number As Integer = 0 For number = 1 To 5 B total = total + number product = product * number Next Console.WriteLine(total) Console.WriteLine(product) Dim total As Integer = 0 Dim product As Integer = 1 Dim number As Integer = 0 For number = 1 To 5 C total = total + number product = product * total Next Console.WriteLine(total) Console.WriteLine(product) Dim total As Integer = 0 Dim product As Integer = 1 Dim number As Integer = 0 For number = 1 To 5 D total = total + number product = (total + product) * number Next Console.WriteLine(total) Console.WriteLine(product)