You are on page 1of 3

import java.io.

*;

public class SquareRoot


{
public static void main(String args[]) throws IOException
{
String str;
int a,i;
BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
System.out.println("Enter the number");
str=br.readLine();
a=Integer.parseInt(str);
i=0;
while(true)
{
if(i*i==a)
{
break;
}
else
i++;
}
if(i*i!=a)
{
System.out.println("the number is not perfect
square");
}
else
System.out.println("squareroot="+i);
}
}
OUTPUT:

CONCLUSION: In this way we calculate squareroot of a perfect


number.

You might also like