title: Call by Reference and Call by Value Result
body: <p>Well, there was a debate on the below code between me and my friend. We're a bit confused about the output it produce. Can someone clarify the call-by-reference and call-by value result for the below piece of code?</p>
  
  <pre><code>program params;
      var i: integer;
      a: array[1..2] of integer;
  
      procedure p(x,y: integer);
      begin
          x := x + 1;
          i := i + 1;
          y := y + 1;
      end;
  
  begin
      a[1] := 1;
      a[2] := 2;
      i := 1;
      p( a[i],a[i] );
      output( a[1],a[2] );
  end.
  </code></pre>
  
  <p>The resulting output of this program in the case that the
  parameters are transmitted to procedure p by value-result and by reference.</p>