Question 7

OCR Computer Science Specimen Paper 2GCSE13 marks

On the specification

(a)
2.3 Producing robust programs
(b)
2.2 Programming fundamentals
(c)(i)
2.2 Programming fundamentals
(c)(ii)
2.2 Programming fundamentals
(d)
2.2 Programming fundamentals
(e)
2.5 Programming languages and IDEs
Question text

7 The area of a circle is calculated using the formula π × r where π is equal to 3.142 and r is the radius. A program is written to allow a user to enter the radius of a circle as a whole number between 1 and 30, then calculate and output the area of the circle. 1 radius = 0 2 area = 0.0 3 radius = input("Enter radius") 4 if radius < 1 OR radius > 30 then 5 print("Sorry, that radius is invalid") 6 else 7 area = 3.142 * (radius ^ 2) 8 print (area) 9 endif (a) Explain, using examples from the program, two ways to improve the maintainability of the program. 1 2 (b) Identify two variables used in the program. 1 2 (c) (i) Identify one item in the program that could have been written as a constant. [1] (ii) Give one reason why you have identified this item as a constant. [1] (d) Tick () one box in each row to identify whether each programming construct has or has not been used in the program. Has been used Has not been used Sequence Selection Iteration (e) An Integrated Development Environment (IDE) is used to write the program. Identify two features of an IDE that might be used when writing the program. 1 2 We advise you to spend at least 40 minutes on this section. Some questions require you to respond using either the OCR Exam Reference Language or a high-level programming language you have studied. These are clearly shown.