Pseudocode is a high-level language which is used to define algorithms for data manipulation. Pseudocode is machine-independent and consists of simple instructions in a human language. Although there is no formal syntax, it is a useful way of outlining the desired data flow in the early stages of development.
The 2014 Computer Science Guide defines a set of rules or conventions governing the coding style of pseudocode. Please note that, for historical reasons, some legacy examples on this wiki may not conform to these conventions. The current conventions can be downloaded as a PDF file from the foot of the page and important highlights are listed here.
- Variable names are all capitals, for example, CITY
- Pseudocode keywords are lower case, for example, loop, if ...
- Method names are mixed case, for example, getRecord
- Methods are invoked using the “dot notation” used in Java, C++, C#, and similar languages, for example, BIGARRAY.binarySearch( 27 )
These will be provided and comments // used, for example:
N = 5 // the number of items in the array SCOREHISTORY.getExam( NUM ) // get the student’s score on exam NUM
Values will be assigned using = , for example:
N = 5 // indicates the array has 5 data items VALUE = 7 // assigns the first data item in the array a value of 7
Output—this term is sufficient to indicate the data is output to a printer, screen, for example:
output COUNT // display the count on the screen
MAX = 0 MIN = 999 COUNT = 0 repeat input TEMP if TEMP > MAX then MAX = TEMP end if if TEMP < MIN then MIN = TEMP end if COUNT = COUNT + 1 until COUNT = 100 output "The maximum temperature is " MAX " and the minimum is " MIN
For... next loop
MAX = 0 MIN = 999 for COUNT = 1 to 100 input TEMP if TEMP > MAX then MAX = TEMP end if if TEMP < MIN then MIN = TEMP end if next COUNT output "The maximum temperature is " MAX " and the minimum is " MIN