Description

The function sqrt() calculates the square root of a number.

Syntax

Use the following function to find the square root of a given number:

sqrt(x)

Parameters

The function admits the following parameter:

x: the number to find the square root of. Allowed data types: any data type.

Returns

The function returns the input number’s square root. Data type: double.

Example Data

Calculate the square root of the x variable:

float x = 9.0;  

void setup() {
  Serial.begin(9600);

  double root = sqrt(x);

  Serial.print("The square root is: ");
  Serial.println(root);
}

void loop() {
}

See also