Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,845 questions

51,766 answers

573 users

How to create and set values to a 3d array in Pascal

1 Answer

0 votes
program ThreeDArray;

const
  x = 2;
  y = 3;
  z = 4;

type
  T3DArray = array[1..x, 1..y, 1..z] of Integer;

var
  array3D: T3DArray;
  i, j, k: Integer;

procedure InitializeArray(var arr: T3DArray);
begin
  for i := 1 to x do
    for j := 1 to y do
      for k := 1 to z do
        arr[i, j, k] := i + j + k; // Initialization
end;

procedure PrintArray(var arr: T3DArray);
begin
  for i := 1 to x do
  begin
    for j := 1 to y do
    begin
      for k := 1 to z do
        Write(arr[i, j, k], ' ');
      Writeln;
    end;
  end;
end;

begin
  InitializeArray(array3D);
  PrintArray(array3D);
end.



(*
run:

3 4 5 6 
4 5 6 7 
5 6 7 8 
4 5 6 7 
5 6 7 8 
6 7 8 9 

*)




 



answered Apr 21, 2025 by avibootz
...