This program demonstrates Pascal's use of several arthmetic functions such as; Square Root(Sqrt), Square(Sqr), Absolute Value(Abs), Truncation(Trunc) and Rounding(Round).
program ArithFunc;
const Sentinel =0.0; var X:Real; begin writeln('After each line enter a real number or 0.0 to stop'); writeln; writeln('X', 'Trunc(x)' :16, 'Round(X)' :10, 'Abs(X)' :10, 'Sqr(X)' :10, 'Sqrt(Abs(X))' :15); readln (X); while X <> Sentinel do begin writeln (Trunc(X) :17, Round(X) :10, Abs(X) :10:2, Sqr(x) :10:2, Sqrt(Abs(X)) :10:2);
readln(X);
end
end.
After each line enter a real number or 0.0 to stop X Trunc(X) Round(X) Abs(X) Sqr(X) Sqrt(Abs(X)) 5.7 5 6 5.70 32.49 2.38 0.0
This program was tested and run using Turbo Pascal 7.0 complier from Borland..