Pseudocode is CASE SENSITIVE. All keywords must be in uppercase.

Declarations

Variables must be declared before they are used or assigned a value. Variables must be declared as a type.


DECLARE variable AS INTEGER
variable = 10

DECLARE name, surname AS STRING
name = "Tom"
surname = "Jones"

        

Arrays must be declared with a value indicating size. Only one array can be declared at a time.


DECLARE variable(10) AS INTEGER
        

Function

Note that function declarations require a type for the return value to be declared.

For these exercises you will need to RETURN a result.

FUNCTION adder(FIRST, SECOND) AS INTEGER 
  DECLARE THEANSWER AS INTEGER
  THEANSWER = FIRST + SECOND
  RETURN THEANSWER
END FUNCTION

Relational Operators

Symbol Meaning
== exactly equals
!= does not equal
+ addition or string concatenation
- subtraction
* multiplication
/ division (float)
MOD remainder (modulo)
> greater than
>= greater than or equal
< less than
<= less than or equal

Logical Operators

Symbol
NOT
AND
OR

If / Else if / Else

In all of the following, the keyword then is optional. All if statements must be on a single line. You can also use end instead of end if
IF NUM < 42 THEN
  // something
END IF
IF NUM < 42 THEN
  // something
ELSE
 // something else
END IF
IF NUM < 42 THEN
  // something
ELSE IF NUM > 55 THEN
 // something else
ELSE
 // more code
END IF

While Loop

DECLARE NUM AS INTEGER
NUM = 0
WHILE NUM < 10 
  OUTPUT NUM
  NUM = NUM + 2
END WHILE

// 0
// 2
// 4
// 6
// 8

For Loop

FOR NUM = 0 TO 4 STEP 1 
OUTPUT (5 - NUM)
END FOR
OUTPUT "Blastoff!"

// 5
// 4
// 3
// 2
// 1
// Blastoff!

Arrays

DECLARE NUMS(3) AS INTEGER
NUMS[0]=42
NUMS[1]=13
NUMS[2]=78
OUTPUT NUMS[0]  // 42
OUTPUT NUMS[2]  // 78
NUMS[1] = 11 // NUMS is now [42, 11, 78]

      

Input

User input can be obtained thus.

DECLARE name AS STRING
INPUT "What is your name?" --> name