ReadyBASIC
BASIC Language Reference Manual > Command and Function Reference >

COS Function

Summary

Calculates the cosine of a given angle (in radians).

Syntax

COS(angle in radians)

Remarks and Examples

The COS function calculates the cosine of an angle, returning the result as a floating-point value.

The angle is assumed to be a value in radians.

To convert degrees to radians, use the formula x * pi / 180, where pi = 3.1415926.

Sample program:

10 INPUT "Enter adjacent length of right triangle: ", ADJACENT
20 INPUT "Enter angle in degrees: ", ANGLEDEGREES
30 PI = 3.1415926
40 ANGLERADIANS = ANGLEDEGREES * PI / 180
50 HYPOTENUSE = ADJACENT / COS(ANGLERADIANS)
60 PRINT "The hypotenuse is ", HYPOTENUSE



Copyright 2006-2008, Kevin Matz, All Rights Reserved.