Saturday 22 June 2013

Write a program in C which checks a number if it is a perfect square or not

 


Code:






#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c;
printf("\nEnter the number:");
scanf("%d",&a);
b=sqrt(a);
c=b*b;
if(c==a)
printf("\n%d is a perfect square.",a);
else
printf("\n%d is not a perfect square.",a);
getch();
}

2 comments: