Java Online Compiler
Example: Java program to calculate the square root of a number using the Math.pow() function
C
C++
C#
Java
Python
PHP
Main.java
STDIN
Run
// Java program to calculate the square root of a number using the Math.pow() function import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("Enter any number to find the square root::\n"); double n = in.nextDouble(); double r; // n = number // r = root /* Calculate square root of number */ r = (double)Math.pow(n, 0.5); // Output System.out.println("\nSquare root of:: " + n + " = " + r + "\n"); } }
25
Output
Clear
ADVERTISEMENTS