Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Semrush - keyword research tool

Turn ChatGPT, Claude, Gemini, And CoPilot Into Your Personal Assistant, Business Coach, Content Creator, And More

AFFILIATE MARKETING Your all-in-one performance engine Manage affiliates, creators, and customer referrals in one unified platform—turning every partnership into measurable growth
Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

42,709 questions

55,473 answers

573 users

How to convert radians to degrees and degrees to radians in Pascal

1 Answer

0 votes
program RadiansDegreesConversion;

{$mode objfpc}{$H+}

{
  Convert radians to degrees and degrees to radians.

  Uses the standard mathematical relationships:
    degrees = radians * (180 / π)
    radians = degrees * (π / 180)

  The Math unit provides the constant Pi and common math utilities.
}

uses
  Math;

{
  Converts radians to degrees.
  Multiplies the input by the ratio between degrees and radians.
}
function ToDegrees(const Radians: Double): Double;
begin
  Result := Radians * (180.0 / Pi);
end;

{
  Converts degrees to radians.
  Multiplies the input by the ratio between radians and degrees.
}
function ToRadians(const Degrees: Double): Double;
begin
  Result := Degrees * (Pi / 180.0);
end;

var
  RadValue: Double;
  DegValue: Double;
  RadToDeg: Double;
  DegToRad: Double;

begin
  { Example values }
  RadValue := 1.0;     { 1 radian }
  DegValue := 180.0;   { 180 degrees }

  { Perform conversions }
  RadToDeg := ToDegrees(RadValue);
  DegToRad := ToRadians(DegValue);

  { Display results }
  WriteLn('Radians: ', RadValue:0:6, ' -> Degrees: ', RadToDeg:0:6);
  WriteLn('Degrees: ', DegValue:0:6, ' -> Radians: ', DegToRad:0:6);
end.



{
run:

Radians: 1.000000 -> Degrees: 57.295780
Degrees: 180.000000 -> Radians: 3.141593

}

 



answered 3 days ago by avibootz

Related questions

...