C Program if else : "Perfect Square root or not Example Using if else" with output
#include <stdio.h>
int main() { int num; printf("Enter a number: "); scanf("%d", &num); // Calculate the square root of the number double squareRoot = sqrt(num); // Check if the square root is an integer if (squareRoot == (int)squareRoot) { printf("%d is a perfect square.\n", num); } else { printf("%d is not a perfect square.\n", num); } return 0; }Enter a number: 16
16 is a perfect square.
Enter a number: 25
25 is a perfect square.
Enter a number: 7
7 is not a perfect square.
Comments
Post a Comment