fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main() {
  5. int number;
  6. double squareRoot;
  7.  
  8. // Input from user
  9. printf("Enter a number: ");
  10. scanf("%d", &number);
  11.  
  12. // Calculate the square root
  13. squareRoot = sqrt(number);
  14.  
  15. // Check if the square of the square root equals the original number
  16. if (squareRoot * squareRoot == number) {
  17. printf("%d is a perfect square.\n", number);
  18. } else {
  19. printf("%d is not a perfect square.\n", number);
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
Enter a number: 32764 is not a perfect square.