Java program to find square root of a number| Latest update in 2019

Basic Java programming exercises

Java Tutorial Java Exercises Data Structures

Write a Java program to input a number and find square root of the given number. How to find square root of a number in Java programming using inbuilt sqrt() function. How to use predefined sqrt() function to find square root in Java program.

Required knowledge

Data types, Basic input/output

Program to find square root of any number
/** * Java program to Find Square root of a Number */ import java.util.Scanner; class Test { public static void main(String arg[]) { double n,sqRoot; Scanner op=new Scanner(; System.out.print("Please Enter any Number : "); n = op.nextDouble(); sqRoot = Math.sqrt(n); System.out.println("\n The Square of a Given Number " + n + " = " + sqRoot); } }


Please Enter any Number : 25 The Square of a Given Number 25.0 = 5.0