Photo AI

5.1 Differentiating between a syntax error and a runtime error is crucial in programming: A syntax error occurs when the rules of the programming language are violated - NSC Information Technology - Question 5 - 2020 - Paper 2

Question icon

Question 5

5.1-Differentiating-between-a-syntax-error-and-a-runtime-error-is-crucial-in-programming:--A-syntax-error-occurs-when-the-rules-of-the-programming-language-are-violated-NSC Information Technology-Question 5-2020-Paper 2.png

5.1 Differentiating between a syntax error and a runtime error is crucial in programming: A syntax error occurs when the rules of the programming language are viola... show full transcript

Worked Solution & Example Answer:5.1 Differentiating between a syntax error and a runtime error is crucial in programming: A syntax error occurs when the rules of the programming language are violated - NSC Information Technology - Question 5 - 2020 - Paper 2

Step 1

5.1.1 Differentiate between a syntax error and a runtime error.

96%

114 rated

Answer

A syntax error occurs when the rules of the programming language are violated, preventing the program from compiling. A runtime error happens during program execution due to unforeseen issues, like dividing by zero.

Step 2

5.1.2 Give TWO guidelines on how a programmer can construct useful error messages.

99%

104 rated

Answer

  1. Explain the error in understandable terms to the user.
  2. Provide an indication whether the error is due to a problem with the software or hardware.

Step 3

5.2 What is the prerequisite for an array to be searched when using the binary search algorithm?

96%

101 rated

Answer

The array needs to be sorted before a binary search can be executed.

Step 4

5.3.1 Give a possible reason for this unexpected result.

98%

120 rated

Answer

The variable 'S' was not initialized, causing it to have a garbage value before being used in the loop.

Step 5

5.3.2 Suggest TWO ways in which to improve the code of the novice programmer to be more readable.

97%

117 rated

Answer

  1. Indentation should be used to clearly present the structure of the code.
  2. Comments should be added to explain the purpose of variables and the logic in the code.

Step 6

5.5 Write an alternative line of Delphi code.

97%

121 rated

Answer

An alternative line of code is Inc(i);.

Step 7

5.6.1 What do the plus (+) and minus (-) symbols represent?

96%

114 rated

Answer

The plus (+) symbol indicates public members, while the minus (-) indicates private members.

Step 8

5.6.2 Identify TWO errors in the class diagram.

99%

104 rated

Answer

  1. The 'setLocation()' method’s parameter does not specify a data type.
  2. The 'getCapacity()' method should explicitly return an integer data type.

Step 9

5.6.3 Identify an auxiliary method in the class diagram provided.

96%

101 rated

Answer

'toString()' is an auxiliary method in the class diagram.

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;