APC-PRAC-011.c (629B)
1 /* Write a program to input positive number and check whether the number is 2 perfect square or not. If the number is negetive then display appropriate message */ 3 4 #include <stdio.h> 5 #include <math.h> 6 7 int main() 8 { 9 int num, temp; 10 printf("Enter the number : "); 11 scanf("%d", &num); 12 if (num < 0) 13 { 14 printf("\nYou entered a negetive number."); 15 return 1; 16 } 17 temp = (int)sqrt(num); 18 if (temp * temp == num) 19 { 20 printf("\nInput %d is a perfect square number.", num); 21 return 0; 22 } 23 else 24 printf("\nInput %d is not a perfect square number.", num); 25 return 0; 26 }