A quality control engineer writes an algorithm to determine whether a solid conical component is within acceptable manufacturing tolerances.
The volume of the cone, VVV, is calculated using its radius r r\,r and height hhh.
If the volume is strictly between 15 and 45, "Pass" is output.
Otherwise, "Fail" is output.
01 r = input("Enter radius")
02 h = input("Enter height")
03 V = (1/3) * 3.14159 * r * h
04 if V > 15 then
05 print("Pass")
06 else
07 print("Fail")
08 endif
The algorithm does not work correctly.
Identify the line number of the two logic errors in the algorithm and write the corrected code for each line.
41 exam-style questions on OCR GCSE Computer Science Designing, creating and refining algorithms. Each one has a worked solution and a mark scheme showing where the marks go.