Pseudocode

From Wikipedia, the free encyclopedia
Jump to: navigation, search

Pseudocode (sometimes written as pseudo-code) is a form of source code that is written for humans, not machines, to read. It is often written to show how an algorithm works.

Examples[change | change source]

FOR I FROM 1 TO 50:
    PRINT I

Reads the for loop and prints all the integers from 1 to 50.


SET X = 1
FOR I FROM 1 TO 16:
    PRINT X
    SET X = X * 2

This pseudocode outputs powers of two.


define AND(A, B) do
    if A then
        return B
    endif
    return 0
end define

The above pseudocode sample computes a logical and function.