Question 5 2018 · October-November · Paper 23 · 10 marks
Reveal official mark-scheme answer
Official answer for Question 5
Question 10
Question 1
Question 2
Question 3
Question 4
Question 5
Question 6
Question 7
Question 8
Question 9
Question 10
Show text version of question
Question 5
The function ReadFileLine() returns a specific line from a text file.
The function takes two parameters:
Identifier Data type Description FileName STRING The name of the text file FileLine INTEGER The line number that is required
The following pseudocode gives an example of the use of the function.
FileData ReadFileLine(FileName, FileLine)
The function ReadFileLine() will:
- open the file, FileName
- read each line from the file until line FileLine is found or the end of the file is reached
- if the line exists, return the string from this line; otherwise return the string "****"
Question 15
Write pseudocode for the ReadFileLine() function.
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
....................................................................................................................................................[10]
Question 16
Appendix Built-in functions (pseudocode) Each function returns an error if the function call is not properly formed.
MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns a string of length y starting at position x from ThisString
Example: MID("ABCDEFGH", 2, 3) returns string "BCD"
LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING returns leftmost x characters from ThisString
Example: LEFT("ABCDEFGH", 3) returns string "ABC"
RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString
Example: RIGHT("ABCDEFGH", 3) returns string "FGH"
LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of ThisString
Example: LENGTH("Happy Days") returns 10
INT(x : REAL) RETURNS INTEGER returns the integer part of x
Example: INT(27.5415) returns 27
ASC(ThisChar : CHAR) RETURNS INTEGER returns the ASCII value of ThisChar
Example: ASC('A') returns 65
IS_NUM(ThisString : STRING) RETURNS BOOLEAN returns the value TRUE if ThisString contains only numeric characters ('0' to '9').
Example: IS_NUM("1234X67") returns FALSE
Operators (pseudocode)
Operator Description Concatenates (joins) two strings & Example: "Summer" & " " & "Pudding" produces "Summer Pudding" Performs a logical AND on two Boolean values AND Example: TRUE AND FALSE produces FALSE Performs a logical OR on two Boolean values OR Example: TRUE OR FALSE produces TRUE
Why this question appears here
99% assigned-topic match · Data types and structures › Data types and records
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9608_w18_qp_23.pdf
