Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
FUNCT.PAS
◄Example► ◄Contents► ◄Index► ◄Back►
PROGRAM funct;
{ FUNCT.PAS : Demonstrates function basics. }
VAR
num, expo, powr : Real;
FUNCTION power( base, exponent : Real ) : Real;
BEGIN
IF (base > 0) THEN
power := Exp( exponent * Ln( base ) )
ELSE
power := -1.0;
END;
BEGIN
Write( 'Enter a number: ' );
Readln( num );
Write( 'Enter an exponent: ' );
Readln( expo );
powr := power( num, expo );
Writeln( num, ' ^ ', expo, ' = ', powr );
END.