Note AcademyNote Academy

Computer Science (AS & A Level) · Oct / Nov 2022 · Paper 22 · Question 7

9618

As printed in the paper

The question as text

A teacher is designing a program to perform simple syntax checks on programs written by students. Two global 1D arrays are used to store the syntax error data. Both arrays contain 500 elements. • Array ErrCode contains integer values that represent an error number in the range 1 to 800. • Array ErrText contains string values that represent an error description. The following diagram shows an example of the arrays. Index ErrCode ErrText 1 10 "Invalid identifier name" 2 20 "Bracket mismatch" 3 50 "Undeclared variable" 4 60 "Type mismatch in assignment" … 500 999 <Undefined> Note: • There may be less than 500 error numbers so corresponding elements in both arrays may be unused. Unused elements in ErrCode have the value 999. The value of unused elements in ErrText is undefined. • Values in the ErrCode array are stored in ascending order but not all values may be present, for example, there may be no error code 31. The teacher has defined two program modules as follows: Module Description OutputError() • takes two parameters as integers: ○ a line number in the student’s program ○ an error number • searches for the error number in the ErrCode array: ○ if found, outputs the corresponding error description and the line number, for example: "Bracket mismatch on line 34" ○ if not found, outputs the line number and a warning, for example: "Unknown error on line 34" SortArrays() sorts the arrays into ascending order of ErrCode

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme
  • 7(a)[6]

  • 7(b)[8]

  • 7(c)(i)[1]

  • 7(c)(ii)[2]

  • 7(c)(iii)[1]

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.