C program to check whether number is Perfect Square or not
In this program, we will read an integer number and check whether it is Perfect Square Number or not. for example number 16 is a Perfect Square Number.
How to implement?/ Explaination
First of all get the square root of the given number and assign this float value into an integer variable, then only integer part of the number will be stored in integer variable after that compare integer and float variables if their values are same it means number is perfect square, because perfect square number's square root does not has float part, if any number has float part it means number is not a perfect square.For example:
- Input a number 16
- Store it's square root in a float variable fVar=4.000
- Assign fVar into iVar (an integer variable) iVar=fVar, it means iVar will contain 4
- Now compare iVar and fVar value will be equal.
- If number does not a perfect square, iVar and fVar will not same.