Question 8 of 22beginner💡 UnderstandVery Short1 mark

Categorise the following as syntax error, logical error or runtime error:

(a)

25 / 0

Answer

Runtime error

(b)

num1 = 25; num2 = 0; num1/num2

Answer

Runtime error

Explanation

According to the textbook section 5.13.3, a runtime error causes abnormal termination of program while it is executing. The statement is correct syntactically, but the interpreter cannot execute it. The textbook explicitly states: 'For example, we have a statement having division operation in the program. By mistake, if the denominator entered is zero then it will give a runtime error like "division by zero".' Both (a) 25/0 and (b) num1/num2 (where num2=0) involve division by zero, which are syntactically correct statements but cannot be executed by the interpreter, hence they are runtime errors.