Perl Programming/Keywords/cos

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Previous: CORE Keywords Next: crypt

The cos keyword[edit | edit source]

cos is the trigonometric function cose that assumes that X is in radians.

Syntax[edit | edit source]

  cos(X)

Examples[edit | edit source]

The code
*PI = \3.1415926535;
$a = 30;	# in degrees
$cos = cos($a/180*$PI);

print "cos(" . $a . "°) = " . $cos . "\n";
prints the cosine of the angle of 30 degrees:


Previous: CORE Keywords Next: crypt