'begin'
	'comment'
		calculate the integral of x^2 for 0 <= x <= 1
	;
	
	'real' 'procedure' calc (p, x0, x1, n);
	'value' x0, x1, n;
	'real' x0, x1;
	'integer' n;
	'begin'
		'real' x, y, yy, dx, sum;

		sum := 0;  dx := (x1 - x0) / (n - 1);
		y := p (x0);

		'for' x := x0+dx 'step' dx 'until' x1 'do' 'begin'
			yy := p (x);
			sum := sum + dx * (yy + y) / 2;
			y := yy
		'end';
		calc := sum
	'end';

	'real' 'procedure' func (xx);
	'value' xx;
	'real' xx;
		func := xx * xx;

	'integer' n;

	'procedure' out (n, x);
	'value' n, x; 'integer' n; 'real' x;
		vprint (n, x);

	vprint ("integral of x^2 for  0 <= x <= 1\n");
	vprint ("                n      sum");
	'for' n := 2, 5, 10, 20, 50, 100, 150 'do'
		out (n, calc (func, 0, 1, n))
'end'
