const
lgth = 2;
amount = 3;
x := lgth * amount;
or
x := lgth *(b + c/a)*amount; {may cause problems if reordered}
for k := 1 to 1000 do c[k] := 2*(p-q)*(n-k+1)/(sqr(n) + n;changes to
fact := 2*(p-q); denom := sqr(n) + n; for k := 1 to 1000 do c[k] := fact*(n-k+1)/denom;
for k := 1 to 1000 do c[k] := 2*(p-q)*fun(k)/(sqr(n) + n;fun might have side effect of changing the "constants" p, q, or n
for i := 1 to 100 do
for j := 1 to 100 do
a[i,j] := b[i,j];
in this loop, computations on i are constant inside the inner loop, so should be removed to a block preceding this inner loop.
i := i + 1;{induction variable eliminated}
offset := i*4 {multiplication replaced by addition}
withoffset := offset + 4;
for i := 1 to 20 do
begin
for j := 1 to 2 do
write(x[i,j]:9:3);
writeln;
end;
unrolled:for i := 1 to 20 do writeln(x[i,1]:9:3,w[i,2]:9:3);Borland claims this is best done by the programmer!
if trace then begin blah,blah,blahwhere trace is set as a constant.
case p of 1: c:= a + b*d; 2: m := b*d -r; 3: f := a-b*d; 4: c:= q/(b*d+r); end; T := b*d; case p of 1: c := a+T; 2: m := T - r; etc.