Introduction to Pseudocode

According to the Oxford English Dictionary, pseudocode is: "a notation resembling a simplified programming language, used in program design". The word "pseudo" can mean "artificial" or "imitation" or "pretend"; therefore, we can think of pseudocode as meaning "artificial, imitation or pretend programming code".

Pseudocode is not a real programming language. Although pseudocode may look like code written in some programming languages, because it may often use similar keywords (such as "print", "input" and "if"), and even follow the same language rules (the grammar or "syntax" of a programming language), there are many different forms of pseudocode which can include statements written in plain English (or other human language).

The purpose of pseudocode is that it can be easily understood by programmers no matter which programming language they are most familiar with, and it is useful for solving problems in a structured, formal way.

Pseudocode is the means by which programming knowledge and computational thinking skills are examined and assessed.

OCR Exam Reference Language

Experience has shown that many novice programming students find pseudocode difficult to learn, particularly if they are familiar with popular high-level programming languages such as Python. Although an excellent language, Python does not have facility for switch-case selection or do-until iteration constructs.

Some variants of BASIC, such as BASIC256, are closer to the form of pseudocode used by some UK examination boards, but BASIC256 does not have an elseif facility as part of its selection syntax.

Using the Scratch-like blocks visual programming paradigm that many novice programmers will already be familiar with, pseudoBlox enables programmers to quickly build programs and solve problems, and then run their programs and see the output right here in the browser, generating perfectly formed and syntactically correct pseudocode in the form of OCR Exam Reference Language, specifically for the J277 GCSE Computer Science qualification.


(pseudoBlox is not endorsed by the OCR exam board.)

Comparison Operators

==
Equal to
!=
Not equal to
<
Less than
<=
Less than or equal to
>
Greater than
>=
Greater than or equal to
 
 

Arithmetic Operators

+
Addition
-
Subtraction
*
Multiplication
/
Division
^
Exponent
MOD
Modulus
DIV
Quotient

Boolean Operators

AND
Logical AND
OR
Logical OR
NOT
Logical NOT
 
 
 
 
 
 
 
 

Comments and Variables

//
Comment
=
Assignment
input(...)
Input
print(...)
Output
float(...)
Cast to float
 
 
 
 
 
 

Selection

if ... then
IF-THEN-ELSE
   // statements
 
elseif ... then
   // statements
 
else
   // statements
 
endif
 
 
 

Selection

switch ... :
SWITCH-CASE
   case ... :
   // statements
 
   case ... :
   // statements
 
   default:
   // statements
 
endswitch
 

Iteration

for ... = ... to ... step ...
FOR-NEXT
   // statements
 
next ...
 
while ...
WHILE-ENDWHILE
   // statements
 
endwhile
 
do
DO-UNTIL
   // statements
 
until ...
 
 
 

String handling

+
Concatenation
.length
String length
.substring(s, n)
Substrings
.left(n)
Substrings
.right(n)
Substrings
(s:starting position, n:number characters)
.upper
Uppercase
.lower
Lowercase
ASC(...)
ASCII to number
CHR(...)
Number to ASCII

File handling

newFile(...)
Create new text file
open(...)
Open existing text file
.close()
Close open text file
.readLine()
Read a line of text
.writeLine(...)
Append line of text
.endOfFile()
End Of File
 
while NOT myFile.endOfFile()
 
   print(readLine())
 
endwhile
 

Arrays

array arrayName[...]
Declaration
arrayName[...] = ...
Assignment
 
 
 
 
 
 
 
 
 
 

Subroutines

procedure procName(...)
Procedure
   // statements
 
endprocedure
 
function funcName(...)
Function
   // statements
 
   return ...
 
endfunction
 

Random

random(... , ...)]
Random number