Skip to main content

A Level ยท Computer Science

Programming: A Level Computer Science

How to turn a design into 9618 pseudocode: declarations, operators and library routines, IF, CASE and the three loops, then procedures, functions, parameters and efficient structure.

  • Lesson
  • 5 quizzes
  • Worksheet PDF

A step-by-step lesson, 5 self-marking quizzes and a printable worksheet, all on Programming for A Level.

Learn it: the lesson

Programming: Pseudocode, Selection, Loops and Subroutines8 steps ยท one idea at a time ยท quick check at the endStart the lesson โ†’
What the lesson covers8 steps ยท tap to see
  1. 1From a design to pseudocode

    A program is rarely written straight from a problem.

    Learn this in the lesson โ†’
  2. 2Constants, variables, assignment, operators and input/output

    Every program stores data in named places.

    Learn this in the lesson โ†’
  3. 3Built-in functions and library routines

    You do not have to write everything yourself.

    Learn this in the lesson โ†’
  4. 4Selection: IF, ELSE, nested IF and CASE

    Selection lets a program choose.

    Learn this in the lesson โ†’
  5. 5Iteration: FOR, WHILE and REPEAT

    Iteration repeats statements.

    Learn this in the lesson โ†’
  6. 6Choosing the right loop

    Any loop can imitate another, so "justify" questions ask why one is better suited.

    Learn this in the lesson โ†’
  7. 7Procedures: defining, calling and when to use one

    A procedure is a named block of code that does a job.

    Learn this in the lesson โ†’
  8. 8Parameters, BYVAL, BYREF and scope

    A procedure that always does the same thing is not very useful.

    Learn this in the lesson โ†’
  9. Quick check: see what you remember

Programming: A Level Computer Science notes

From a design to pseudocode

A program is rarely written straight from a problem. First comes a design, usually a flowchart or a description in structured English. Your job is then to turn it into pseudocode (or real code) that does exactly what the design says. The flowchart on the right and the pseudocode beside it describe the same program.

Work through the design one symbol at a time:

  1. Each parallelogram becomes an INPUT or OUTPUT statement.
  2. Each rectangle becomes one or more assignments using โ†.
  3. Each diamond becomes the condition of an IF (two arrows out) or of a loop (when an arrow goes back up).
  4. The rounded boxes need no code, but they tell you where the program begins and ends.

With structured English the words are your outline. "Repeat until" becomes REPEAT ... UNTIL, "if ... otherwise" becomes IF ... ELSE, and each indented step is indented in your code too. Indentation is not decoration in pseudocode: it shows which statements belong inside which structure.

Before you write a line, find every place where the flowchart branches or loops back. Those are your IF and loop statements. Everything else is a plain sequence.

Key facts

  • First comes a design, usually a flowchart or a description in structured English.
  • The right-hand side of an assignment is an expression.
  • Choose the identifier names a stranger could understand without a comment.
  • A library routine is a tested subroutine that comes with the language.
  • Selection lets a program choose.
  • A count-controlled loop uses FOR counter โ† start TO end with an optional STEP.

Programming MCQs with answers

Tap an answer to check it.

  1. Which pseudocode statement declares a variable that will hold whole numbers?

    Answer: D. DECLARE Total : INTEGER The pseudocode form is DECLARE name : type, so DECLARE Total : INTEGER.

  2. When is a CASE structure the most suitable choice?

    Answer: A. When one variable is compared with several specific values CASE suits a choice among several specific values of one variable, replacing a long chain of IF statements.

  3. What is output? x โ† 7 y โ† x DIV 2 z โ† x MOD 2 OUTPUT y + z

    Answer: A. 4 7 DIV 2 = 3 (whole-number division) and 7 MOD 2 = 1 (remainder), so y + z = 3 + 1 = 4.

  4. What is the final value of Total? Total โ† 0, then FOR I โ† 1 TO 4 with Total โ† Total + I * 2 in the body, then NEXT I.

    Answer: B. 20 The loop adds 2, 4, 6 and 8, so Total = 2 + 4 + 6 + 8 = 20.

More questions in the 5 quizzes below โ†“ ยท All A Level Computer Science MCQs with answers โ†’

Practise real quizzes on this topic: 5 quizzes

Each quiz marks itself the moment it is finished and explains every answer. Start easy and work up.

๐Ÿ–จ๏ธProgrammingA printable A Level Computer Science 9618 worksheet on programming: constants, variables and built-in functions, IF, CASE and the three loop types, then procedures, functions, parameters and efficient pseudocode.See the worksheet โ†’

โฌ‡ Download free PDFFree sample copy with a light QuizByt mark. A free account gives you more.