#include <stdio.h>
#include <math.h>
int main(void)
{
int number;
double result;
printf ("\n Introduce an integer: ");
scanf ("%i", &number);
result= sqrt (number);
if ((result * result)== number)
printf ("\n The integer HAS a perfect square \n\n");
else
printf ("\n The integer DOES NOT HAVE a perfect square \n\n");
}
although, this code gives me correct output for values, but i wana ask is it the right way to check that a number is a perfect square ? as i am taking result as double which always a approximate value so multiplying this (result*result) will give me the correct output ? thanks in advance.