HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

the convention for declaring arrays in pseudocode

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
thearraysconventionpseudocodedeclaringfor

Problem

I have a very simple question.
What is the right standard convention to use for declaring arrays?

I understand that for a simple declaration of a variable as an integer, this is the convention:

DECLARE myVar : INTEGER


What about for an integer array of 10 elements?

DECLARE myVar : ARRAY[1,10] of INT


or

DECLARE myVar[1,10] : ARRAY of INT


or something else?

Solution

Pseudocode is not a formal language. Declare your arrays however you want, as long as it's obvious what you mean. Including the full limits (as you have in both your array examples) is good, since it means the reader isn't worrying about whether you start your indices at 0 or 1.

Context

StackExchange Computer Science Q#42226, answer score: 9

Revisions (0)

No revisions yet.