Question 6

OCR Computer Science June 2018 Paper 2GCSE7 marks

On the specification

(a)
2.1 Algorithms2.2 Programming techniques
(b)
2.1 Algorithms2.2 Programming techniques
Question text

6 An infinite loop is where a section of a program repeats indefinitely. (a) For each of the pseudocode algorithms shown below, tick the appropriate box to show whether they will loop infinitely or not. Pseudocode Will loop infinitely Will not loop infinitely 1 x = 0 2 while True 3 print x 4 endwhile 1 x = 0 2 while x < 10 3 print x 4 endwhile 1 x = 0 2 while x < 10 3 print x 4 x = x + 1 5 endwhile 1 y = 5 2 for x = 1 to y 3 print x 4 next [4] (b) Using pseudocode, write an algorithm that will use a count-controlled loop to print out the numbers 1 to 10 in ascending order. [3]