Sunday 15 March 2015

To find the given no. is perfect square or not Using C

# include <stdio.h>
# include <conio.h>
# include <math.h>


void main()
{
int m, n ;
float p ;
clrscr() ;
printf("Enter a number : ") ;
scanf("%d", &n) ;
p = sqrt(n) ;
m = p ;
if (p == m)
printf("\n%d is a perfect square", n) ;
else
printf("\n%d is not a perfect square", n) ;
getch() ;
}


RUN 1 :
~~~~~~~
Enter a number : 81
81 is a perfect square
RUN 2 :
~~~~~~~
Enter a number : 12
12 is not a perfect square

No comments:

Post a Comment