Create a two-dimensional array at runtime: Difference between revisions
Create a two-dimensional array at runtime (view source)
Revision as of 20:05, 1 August 2023
, 9 months agoadded ALGOL-M example
m (added ALGOL-M example) |
|||
Line 487:
</pre>
==={{header|ALGOL-M}}===
<syntaxhighlight lang="ALGOL">
begin
integer first, second;
write("Two Dimensional Array Exercise");
write("Length of first dimension:");
read(first);
write("Length of second dimension:");
read(second);
begin % we need to start a new block %
integer array test[1:first, 1:second];
integer i, j;
i := first - 1;
j := second - 1;
test[i,j] := 99;
write("Stored value =",test[i,j]);
end; % array is now out of scope %
end
</syntaxhighlight>
{{out}}
<pre>
Two Dimensional Array Exercise
Length of first dimension:
->6
Length of second dimension:
->7
Stored value = 99
</pre>
=={{header|ALGOL 68}}==
|