COS Example
10 ! This example demonstrates the usage of the trigonometric
20 ! functions. The following triangle will be used:
30
40 ! |\
50 ! | a\ Given C = 4 units and angle
60 ! C| \B c = 53.1301023542 degrees
70 ! |b c\ Note: angle b = 90 degrees.
80 ! +--------
90 ! A
100 CLEAR SCREEN
110 DEG ! get in degree mode
120 REAL A,B,C
130 ! Given:
140 C=4
150 Angle_c=53.1301023542
160 Angle_b=90
170 ! Angle a can be found by simply subtracting the total given
180 ! angles by 180 degrees. Every triangle only has 180
190 ! degress.
200 Angle_a=180-(Angle_c+Angle_b)
210 ! The sine of angle c is defined as C over B. Solving for
220 ! B gives us:
230 B=C/SIN(Angle_c)
240 ! The cosine of angle c is defined as A over B. Solving for
250 ! A gives us:
260 A=B*COS(Angle_c)
270 ! To double check the answers, one possible way is:
280 ! Given: A^2 + C^2 = B^2 and solving for C
290 IF SQR(B^2-A^2)=C THEN
300 PRINT "The leg A =";A;"units."
310 PRINT "The leg B =";B;"units."
320 PRINT "The leg C =";C;"units."
330 PRINT "Angle a is = ";Angle_a;"degrees."
340 PRINT "Angle b is = ";Angle_b;"degrees."
350 PRINT "Angle c is = ";Angle_c;"degrees."
360 ELSE
370 PRINT "An error has occurred."
380 END IF
390 END