Question 4(c) 2017 · May-June · Paper 22 · 42 marks
Reveal official mark-scheme answer
The answer for this question is in the official mark scheme: open the mark scheme.
Show text version of question
Question 4
Part (c)
Question 4
WRITEFILE (MyFile, "Data is " & String2)
Part (b)
(i)
Complete the following two sentences.
(ii)
The following table shows the values of three variables.
Variable Value FlagA TRUE FlagB FALSE FlagC TRUE
Evaluate these expressions.
Expression Evaluates to
(FlagA AND FlagB) OR FlagC
FlagA AND (FlagB OR FlagC)
(NOT FlagA) OR (NOT FlagC)
Question 3
Part (c)
The loop construct (also known as repetition or iteration) appears in many algorithms.
Use pseudocode to write a post-condition loop to output all the odd numbers between 100 and 200.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
..............................................................................................................................................
Question 4
2 A multi-user computer system maintains a text file containing the ID and preferred name for each user. User IDs are unique. Preferred names may be repeated.
Part (c)
The file may not contain an entry for every user. If the user ID is not found, then the name
“Guest” should be used as the preferred name.
Use structured English to write a more detailed algorithm for the welcome message process described in part (a).
Use the identifiers given in the previous table.
Assume that the file, UserNames.txt, is organised as a simple text file. The user ID and preferred name are held together in unencrypted form, one entry per line.
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
...................................................................................................................................................
..............................................................................................................................................
Question 6
3 A string conversion function, ExCamel, needs to be written.
This function forms a return string, OutString, from a given string, InString, by:
1 separating the original words (a word is assumed to start with a capital letter) 2 converting all characters to lower case.
The following shows a pair of example values for the string values InString and OutString.
InString : "MyUserInput" OutString : "my user input"
You may assume that InString always starts with a capital letter.
The following is a first attempt at writing the pseudocode for this function.
Complete the pseudocode using appropriate built-in functions.
For the built-in functions list, refer to the Appendix on page 13.
FUNCTION ExCamel (............................) RETURNS .............
DECLARE NextChar : ............................................
DECLARE ...................................................... : STRING
DECLARE n: INTEGER
........................................... // initialise the return string
// loop through InString to produce OutString
FOR n 1 TO .............................. // from first to last
NextChar ............................. // get next character
IF ...................................... // check if upper case
THEN
IF n > 1 // if not first character
THEN
............................. // add space to OutString
ENDIF
................................... // make NextChar lower case
ENDIF
......................................... // add NextChar to OutString
ENDFOR
............................................ // return value
ENDFUNCTION
Question 7
Question 4
Part (a)
High-level programming languages have many features that support the modular approach.
One such feature is the use of parameters.
State two other features.
1 ...............................................................................................................................................
...................................................................................................................................................
2 ...............................................................................................................................................
...................................................................................................................................................
Part (b)
Consider the following pseudocode.
PROCEDURE MyProc(x) x x + 1 ENDPROCEDURE
Intermediate lines of pseudocode not shown
x 4 CALL MyProc(x) OUTPUT(x)
Parameter x is used to pass data to procedure MyProc. There are two parameter passing methods that could be used.
Complete the following table for each of the two methods.
Name of parameter Value Explanation passing method output
...................................................................................... ................................. ............. ...................................................................................... ................................. ......................................................................................
...................................................................................... ................................. ............. ...................................................................................... ................................. ......................................................................................
Question 8
Why this question appears here
72% assigned-topic match · Programming › Constructs
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_s17_qp_22.pdf
