Main Page | See live article | Alphabetical index

Pseudocode

Pseudocode is generic way of describing an algorithm without use of any specific programming language-related notations. It is, as the name suggests, pseudo code. That is, it is not really programming code, but it models and may even look like programming code. Pseudocode, by nature, exists in various forms, though most borrow syntax from popular programming languages (like C, Lisp, or Fortran). Natural language text is used whenever details are unimportant or distracting.

Computer science text books often use pseudocode in their examples so that all programmers can understand them, even if they do not all know the same programming languages. Since psuedocode style varies from author to author, there is usually an accompanying introduction explaining the syntax used.

Wikipedia's style of pseudocode uses keywords from C for the some common operations, and, like Python, uses indentation to distinguish the scope of things like loops. However, not all documents yet adhere to this standard.

Example Wikipedia pseudocode

Assignment:

 = 

Conditionals:

if 
 do stuff
else
 do other stuff

Simple loops:

while 
 do stuff

for from to by
 do stuff with variable

Function calls:

()

Function declarations:

function ()
 do stuff with arguments
 return something (optional)

Variable declarations:

declare  as 

Array declarations:

declare [ to ] of 

Composite data structures (also see Object Oriented Programming):

struct 
 

Accessing fields of a composite structure:

.

This standard still needs work.