Jump to content

Length of an arc between two angles: Difference between revisions

Added Algol 68
m (→‎{{header|Wren}}: Changed to Wren S/H)
(Added Algol 68)
Line 142:
</syntaxhighlight>
 
==={{header|ALGOL W68}}==
{{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
3,060

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.