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

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,844 questions

55,671 answers

573 users

How to find the maximum value in a multidimensional array with Pascal

1 Answer

0 votes
program FindMaxInMultiDimArray;

var
  arr: array[1..4, 1..3] of Real; // Define a 2D array (4 rows, 3 columns) of real numbers
  maxValue: Real;
  i, j: Integer;

begin
  // Initialize the 2D array with values
  arr[1, 1] := 1;     arr[1, 2] := 2;     arr[1, 3] :=  3.14;
  arr[2, 1] := 1;     arr[2, 2] := 1;     arr[2, 3] := 16.80;
  arr[3, 1] := 3;     arr[3, 2] := 5;     arr[3, 3] := 17.50;
  arr[4, 1] := 2;     arr[4, 2] := 4;     arr[4, 3] := 11.03;

  // Initialize maxValue to a very small number
  maxValue := -MaxInt; 

  // Traverse the array to find the maximum value
  for i := 1 to 4 do
    for j := 1 to 3 do
    begin
      if arr[i, j] > maxValue then
        maxValue := arr[i, j]; // Update maxValue
    end;

  WriteLn('The maximum value in the array is: ', maxValue:0:2);
end.




(*
run:

The maximum value in the array is: 17.50

*)

 



answered Apr 5, 2025 by avibootz
...