Program to check whether the given number is a perfect square or not
x=input("Enter the number : ")
ans = 0
if x >= 0:
while ans*ans < x:
ans = ans + 1
if ans*ans != x:
print x, "is not a perfect square."
else:
print x, " is a perfect square."
OUTPUT :
Enter the number : 16
16 is a perfect square.
Enter the number : 25
25 is a perfect square.
Enter the number : 24
24 is not a perfect square.
No comments