±«Óătv

Decomposition and algorithm practice questions - EdexcelWriting your answer

Pseudocode questions need to be analysed and decomposed before writing an answer. The question may give hints about possible program structures to use. You do not need to memorise pseudocode, and errors are acceptable as long as the meaning is clear.

Part of Computer ScienceStudy skills

Writing your answer

Once you’ve thought about how you’ll meet each individual requirement, you need to write the answer in . Remember, you can add comments to pseudo-code by putting a # at the start of the comment. Comments in pseudo-code questions enable you to explain things that aren’t obvious to the examiner.

SET looping TO TRUE     #used to keep the loop running until the user wants to quit

WHILE looping = TRUE DO     #loop to keep asking for identifiers

     #get identifier from user

     RECEIVE identifier FROM (STRING) KEYBOARD

     IF identifier = ‘Q’ THEN     #user wants to quit

          SET looping TO FALSE     #loop won’t run again as condition will be false

          SEND ‘Bye’ TO DISPLAY

ÌęÌęÌęÌęÌę·Ąłął§·Ą IF LENGTH (identifier) <> 9 THEN

          SEND ‘The customer identifier is not nine characters long’ TO DISPLAY

ÌęÌęÌęÌęÌę·Ąłął§·Ą

          #check last 3 characters

          SET badAlpha TO FALSE #this is a flag that will be changed to TRUE if a non-uppercase letter is found

          FOR count FROM 6 TO 8 DO

               IF (NOT (identifier[count] >= ‘A’ AND identifier[count] <= ‘Z’)) THEN

               SEND ‘Bad character in last 3 characters found’ TO DISPLAY

               SET badAlpha TO TRUE

          END IF

     END FOR

     IF badAlpha = FALSE THEN

          SEND ‘Final three characters are valid’ TO DISPLAY

     END IF

END IF

It is important to use easy-to-understand names and use indentation correctly as this will make the pseudo-code easier to read and help you gain maximum marks.