home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
cpm
/
turbopas
/
ttutor2.lbr
/
PROG12A.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1985-08-02
|
768b
|
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.