# Java Program to Find Square root of a Number

Write a Java Program to Find Square root of a Number using Math.sqrt and without using sqrt function with example.

## Java Program to Find Square root of a Number Example 1

This Java program allows the user to enter integer value, and then finds the square root of that number using math function Math.sqrt

```// Java Program to Find Square root of a Number
import java.util.Scanner;

public class SqrtofNumber1 {
private static Scanner sc;
public static void main(String[] args)
{
double number, squareRoot;
sc = new Scanner(System.in);

System.out.print(" Please Enter any Number : ");
number = sc.nextDouble();

squareRoot = Math.sqrt(number);

System.out.println("\n The Square of a Given Number  " + number + "  =  " + squareRoot);
}
}```

## Java Program to Find Square root of a Number Example 2

In this Program, we are using the math function Math.pow to find the square root of a number. As we all know √number = number½

```// Java Program to Find Square root of a Number
import java.util.Scanner;

public class SqrtofNumber2 {
private static Scanner sc;
public static void main(String[] args)
{
double number, squareRoot;
sc = new Scanner(System.in);

System.out.print(" Please Enter any Number : ");
number = sc.nextDouble();

squareRoot = Math.pow(number, 0.5);

System.out.println("\n The Square of a Given Number  " + number + "  =  " + squareRoot);
}
}```

Java square root of a number output

`````` Please Enter any Number : 625

The Square of a Given Number  625.0  =  25.0``````