Question 8
OCR Computer Science Sample papers Paper 2GCSE12 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.5 Programming languages and IDEs
Question text
8 The area of a circle is calculated using the formula π × r , where π is equal to 3.142 and r is the radius. Finn has written a program to allow a user to enter the radius of a circle as a whole number, between 1 and 30, and output the area of the circle. 1 int radius = 0 2 real area = 0.0 3 input 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 end if (a) Explain, using examples from the program, two ways Finn can improve the maintainability of the program. Specimen (b) Identify two variables used in the program. (c) (i) Identify one item in the program that could have been written as a constant. (ii) Give one reason why you have identified this item as a constant. (d) Finn uses an IDE (Integrated Development Environment) to write his programs. Identify two features of an IDE that Finn might use. Specimen Specimen Specimen