program PointerArithmeticDemo;
var
  a: array [1 .. 7] of Char;
  p, q: ^Char;
  i: Integer;

{$X+} { We need extended syntax for pointer arithmetic }

begin
  for p := @A[1] to @A[7] do
    p^ := 'x';

  p := @A[7];
  q := @A[3];
  while p > q do
    begin
      p^ := 'y';
      Dec (p)
    end;

  p := @A[7];
  q := @A[3];
  i := q - p;    { yields 4 }
end.
