Java program to find square root of a number

Java program to find square root of a number

Java program to find square root of a number using math operation

Java program to find square root of a number using math.sqrt

Program:-

import java.util.Scanner;

class group{
public static void main(String angt[]){
Scanner data = new Scanner(System.in);
double num;
System.out.println("Enter a number");
num=data.nextInt();
// Finding square root of the number
num=Math.sqrt(num);
System.out.println("max number:"+num);
}
}

Output:-

Enter a number
16
max number:4.0


Output:-

Enter a number
5
max number:2.23606797749979



Learn Java:-

Java codes

Java Programs:-

List of Java Programs



Leave reply

Add your comments here

Back to Top