Declaring Variables and Arrays

Introduction to Declaring Variables and Arrays in Pseudonaja

This guide is going to take you through the process of basic declaration of variables in Pseudonaja.

Basic Variables

To use variables in Pseudonaja we first need to declare the variable. This can be done using the following command:

DECLARE <variable name> : <data type>

An example of this is:

DECLARE num1 : INTEGER

You can also use commas to DECLARE multiple variables

DECLARE num1, num2, num3 : INTEGER

Available data types:

Datatype Command
Type

INTEGER

A single integer number

REAL

A single float / real number

BOOLEAN

A binary TRUE or FALSE value

CHAR

A single character

STRING

A string of multiple characters

ARRAY

An array of fixed length of a particular data type

num1 <- 3

Arrays

In pseudocode you declare arrays slightly differently:

An example of this is:

Two dimensional arrays are declared as follows:

An example of this is:

Accessing Arrays

To access a 1D array:

To access a 2D array:

Where the first value within the assignment statement is the row to be accessed, and the second value is the column to be accessed.

Last updated

Was this helpful?