C Program to Check if Given Number is Perfect Square or Not
Write C Program to Check if Given Number is Perfect Square or Not
//Write C Program to Check if Given Number is Perfect Square or Not #include <stdio.h> #include <math.h> int main() { int n; printf("Enter the number :--> "); scanf("%d", &n); if(pow((int)sqrt(n), 2) == n) { printf("Perfect Square "); } else { printf("Not a perfect square"); } return 0; }
Output:
Run 1:
Enter the number :--> 4
Perfect Square
Run 2:
Enter the number :--> 89
Not a perfect square