program PerfectSquareCheck;
uses
Math; // For sqrt function
// When a square root is a whole number, then the number is a perfect square number
function IsPerfectSquare(number: Integer): Boolean;
var
d_sqrt: Double;
begin
if number >= 0 then
begin
d_sqrt := Sqrt(number);
// Check if the square of the square root equals the original number
IsPerfectSquare := Trunc(d_sqrt) * Trunc(d_sqrt) = number;
end
else
IsPerfectSquare := False;
end;
var
num: Integer;
begin
num := 81;
if IsPerfectSquare(num) then
WriteLn(num, ' is a perfect square')
else
WriteLn(num, ' is not a perfect square');
end.
(*
run:
81 is a perfect square
*)