Many times it happens that while solving mathematical expressions we require to calculate the square root of a number.
To solve this issue, like other programming language Perl provides us with a built-in function sqrt() which can be used to calculate the square root of a number.
Perl
Perl
Syntax: sqrt value Returns: square root of the value passedNote: sqrt() can only calculate square root of positive values. Example 1:
#!/usr/bin/perl
# Calculating square root using sqrt()
$square_root = sqrt(64);
# Printing the result
print "Squareroot of 64 is: $square_root";
Output:
Example 2:
Squareroot of 64 is: 8
#!/usr/bin/perl
# Calculating square root using sqrt()
$square_root = sqrt(16);
# Printing the result
print "Squareroot of 16 is: $square_root";
Output:
Squareroot of 16 is: 4