home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
CPM
/
UTILS
/
S
/
TPTUTOR2.ARC
/
PROG12A.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-06-28
|
739b
|
40 lines
PROGRAM PROG12A;
{$U+ Copyright (C), 1985 by Lyle Faurot. All rights reserved.
New Topics: Writing your own function
}
VAR
No : Integer;
FUNCTION Has_Valid_Cube(Number:Integer) : Boolean;
BEGIN
If (Number < -32) OR (Number > 31)
THEN
Has_Valid_Cube := False
ELSE
Has_Valid_Cube := True;
END;
FUNCTION Cube(Number:Integer) : Integer;
BEGIN
Cube := Number * Number * Number;
END;
BEGIN
Write('Enter a number: ');
ReadLn(No);
If Has_Valid_Cube (No)
THEN
WriteLn('The cube is: ', Cube(No) )
ELSE
BEGIN
WriteLn('The cube of ',No,' is outside the integer range');
WriteLn('in this version of Pascal.');
END;
END.