Home >>c programs >C program to check whether number is Perfect Square or not
In this example, we will see a C program through which we can check if a given number is a perfect square or not.
If a whole number is the square of another whole number then it is known as a perfect square, like 16 is the square of 4 so 16 will be called a Perfect square.
Algorithm:
/*C program to check number is perfect square or not.*/
#include <stdio.h>
#include <math.h>
int main()
{
int num;
int iVar;
float fVar;
printf("Enter an integer number: ");
scanf("%d",&num);
fVar=sqrt((double)num);
iVar=fVar;
if(iVar==fVar)
printf("%d is a perfect square.",num);
else
printf("%d is not a perfect square.",num);
return 0;
}