Trusted answers to developer questions

okwudili onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

In Dart, the ** sqrt() function** returns the positive square root of a value. It can be used when the

`dart:math`

package is imported.```
double sqrt(num x)
```

`sqrt()`

converts `x`

to a `double`

and returns the positive square root of the value.

The `sqrt()`

method returns the positive square root of the value. It returns `-0.0`

if `x`

is -0.0, and `NaN`

if `x`

is otherwise negative or NaN.

The following code demonstrates how to use the `sqrt()`

function in Dart.

// import the math package that has the sqrt() methodimport 'dart:math';void main() {// create our number valuesdouble no1 = 4.00;int no2 = 16;int no3 = 15;int no4 = 1600;// print the squre rootsprint("square root of ${no1} is ${sqrt(no1)}");print("square root of ${no2} is ${sqrt(no2)}");print("square root of ${no3} is ${sqrt(no3)}");print("square root of ${no4} is ${sqrt(no4)}");}

When we pass negative values, we get a `NaN`

value.

// import the math package that has the sqrt() methodimport 'dart:math';void main() {// create our number valuesdouble no1 = -0.0;int no2 = -16;int no3 = -15;int no4 = -1600;// print the squre rootsprint("square root of ${no1} is ${sqrt(no1)}");print("square root of ${no2} is ${sqrt(no2)}");print("square root of ${no3} is ${sqrt(no3)}");print("square root of ${no4} is ${sqrt(no4)}");}

RELATED TAGS

dart

squareroot

communitycreator

CONTRIBUTOR

okwudili onyejiaku

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses