Square root#8672

Square root (Editorial)

To compute the square root, use the sqrt function from the <math.h> library.

Algorithm implementation

Read the input value of .

scanf("%lf",&x);

Compute and print the square root of the number .

y = sqrt(x);
printf("%.6lf\n",y);

Java implementation

import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner con = new Scanner(System.in); 
    double x  = con.nextDouble();
    double y = Math.sqrt(x);
    System.out.printf("%6f\n",y);
    con.close();
  }
}

Python implementation

import math

Read the input value of .

x = float(input())

Compute and print the square root of the number .

y = math.sqrt((x))
print(y)