< Perl Programming < Keywords

The code
prints the sine of the angle of 30 degrees:
The sin keyword
sin is the trigonometric function sine that assumes that X is in radians.
Syntax
sin(X)
Examples

*PI = \3.1415926535;
$a = 30; # in degrees
$sin = sin($a/180*$PI);
print "sin(" . $a . "°) = " . $sin . "\n";
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.