% hw0091.m
% John Burkardt
% Estimate average distance between random points in unit square.
%
n = input ( 'Enter number of tests N: ' );
dsum = 0.0;

for i = 1 : n
  x1 = rand ( );
  y1 = rand ( );
  x2 = rand ( );
  y2 = rand ( );
  d = sqrt ( ( x1 - x2 )^2 + ( y1 - y2 )^2 );
  dsum = dsum + d;
end
fprintf ( 'The average distance is %g\n', dsum / n );
