
Data Structure

This illustrates a data structure, a means of storing data within a program.

You may see other such structures in the Data Structures category.
Get two integers from the user, then create a two-dimensional array where the two dimensions have the sizes given by those numbers, and which can be accessed in the most natural way possible. Write some element of that array, and then output that element. Finally destroy the array if not done by the language itself.

decl int width height
out "width:  " console
set width (in int console)
out "height: " console
set height (in int console)
 
decl int<><> twodstream
for (decl int i) (< i height) (inc i)
        append (new int<>) twodstream
end for
for (set i 0) (< i height) (inc i)
        decl int j
        for (set j 0) (< j width) (inc j)
                append 0 twodstream<i>
        end for
end for
 
set twodstream<0><0> 5
out twodstream<0><0> endl console