Length of an arc between two angles: Difference between revisions
Length of an arc between two angles (view source)
Revision as of 13:04, 31 December 2023
, 6 months agoAdded Algol 68
m (→{{header|Wren}}: Changed to Wren S/H) |
(Added Algol 68) |
||
Line 142:
</syntaxhighlight>
==={{header|ALGOL
{{Trans|ALGOL W}}
<syntaxhighlight lang="algol68">
BEGIN
# returns the length of the arc between the angles a and b on a circle of radius r #
# the angles should be specified in degrees #
PROC major arc length = ( REAL a, b, r )REAL:
BEGIN
REAL angle := ABS ( a - b );
WHILE angle > 360 DO angle := angle - 360 OD;
IF angle < 180 THEN angle := 360 - angle FI;
( r * angle * pi ) / 180
END # majorArcLength # ;
# task test case #
print( ( fixed( major arc length( 10, 120, 10 ), -10, 4 ), newline ) )
END
</syntaxhighlight>
{{out}}
<pre>
43.6332
</pre>
={{header|ALGOL W}}==
Follows the Fortran interpretation of the task and finds the length of the major arc.
<syntaxhighlight lang="algolw">begin
|