5.3 Solutions

    1. 12 x 21 = 252
    2. 10 x 21 = 210
    3. 11 x 11 = 121
    4. 5 x 5 x 5 = 125
    5. 9 x 6 = 54
    1. The name of the array is missing. Should be something like:
      var a : array 1 .. 10, 0 .. 4 of real
    2. low and high should be defined constants. Should be something like:
      const LOW := 1
      const HIGH := 10
      var table : array LOW .. HIGH, LOW .. HIGH of char
    3. Colon is missing and second index needs to go from low to high:
      var scores : array -5 .. 10, -10 .. 5 of int 
    4. The word array is missing:
      var matrix : array 1 .. 10, 1..10 of real 
    1.  
      4 3 2 1 8 7 6 5 
    2.  
      8 7 6 5 4 3 2 1 
    3.  
      1 5 2 6 3 7 4 8 
    4.  
      4 8 3 7 2 6 1 5 
  1. % 4a
    var four : array 1 .. 3, 1 .. 5 of int
    
    % 4b
    for row : 1 .. 3
       for col : 1 .. 5
          four(row, col) := 0
       end for
    end for
    
    % 4c
    var grandTotal : int := 0
    for row : 1 .. 3
       for col : 1 .. 5
          grandTotal := grandTotal + four(row, col)
       end for
    end for
    
    % 4d
    var row2sum : int := 0
    for col : 1 .. 5
       row2sum := row2sum + four(2, col)
    end for
    
    % 4e
    var col3sum : int := 0
    for row : 1 .. 3
       col3sum := col3sum + four(row, 3)
    end for
    
    % 4f
    var negSum : int := 0
    for row : 1 .. 3
       for col : 1 .. 5
          if four(row, col) < 0 then
             negSum := negSum + four(row, col)
          end if
       end for
    end for
    
    % 4g
    for row : 1 .. 3
       for col : 1 .. 5
          four(row, col) := four(row, col) ** 2
       end for
    end for
    
    % 4h
    var largest : int := four(1, 1)
    for row : 1 .. 3
       for col : 1 .. 5
          if four(row, col) > largest then
             largest := four(row, col)
          end if
       end for
    end for