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
1From a design to pseudocode
A program is rarely written straight from a problem.
Learn this in the lesson โ2Constants, variables, assignment, operators and input/output
Every program stores data in named places.
Learn this in the lesson โ3Built-in functions and library routines
You do not have to write everything yourself.
Learn this in the lesson โ4Selection: IF, ELSE, nested IF and CASE
Selection lets a program choose.
Learn this in the lesson โ5Iteration: FOR, WHILE and REPEAT
Iteration repeats statements.
Learn this in the lesson โ6Choosing the right loop
Any loop can imitate another, so "justify" questions ask why one is better suited.
Learn this in the lesson โ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 โ8Parameters, BYVAL, BYREF and scope
A procedure that always does the same thing is not very useful.
Learn this in the lesson โ- 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:
- Each parallelogram becomes an INPUT or OUTPUT statement.
- Each rectangle becomes one or more assignments using โ.
- Each diamond becomes the condition of an IF (two arrows out) or of a loop (when an arrow goes back up).
- 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.
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.
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.
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.
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.
Print it: the worksheet Save to Pinterest
๐จ๏ธ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.
Programming in other classes
All A Level Computer Science topics
- Information Representation
- Communication
- Hardware
- Processor Fundamentals
- System Software
- Security, Privacy and Data Integrity
- Ethics and Ownership
- Databases
- Data Types and Structures
- Programming
- Software Development
- Data Representation (A Level)
- Communication and Internet Technologies
- Hardware and Virtual Machines
- System Software (A Level)
- Security (A Level)
- Artificial Intelligence
- Computational Thinking and Problem-solving
- Further Programming
- Algorithm Design and Problem-Solving