# Program to convert Degree to Radian

Last Updated : 29 Oct, 2023

Given the angle in degree, the task is to convert this into radians.
Examples:

`Input: degree = 45 Output: radian = 0.785398Input: degree = 58Output: radian = 1.01229 `

Approach:
Radian: The Radian is the SI unit for measuring angles, used mainly in trigonometry. A radian is defined by an arc of a circle. A full circle is just over 6 radians (Roughly 6.28). One radian is just under 57.3 degrees.
Degree: A degree, usually denoted by Â° (the degree symbol), is a measurement of a plane angle, defined so that a full rotation is 360 degrees. Because a full rotation equals 2*pi radians, one degree is equivalent to pi/180 radians.
The formula to convert radian to degree is:

`radian = degree * (pi/180) where pi = 22/7`

Below is the implementation of the above approach:

## C++

 `// C++ program to convert degree to radian`   `#include ` `#include ` `using` `namespace` `std;`   `// Function for conversion` `double` `Convert(``double` `degree)` `{` `    ``double` `pi = 3.14159265359;` `    ``return` `(degree * (pi / 180));` `}`   `// Driver code` `int` `main()` `{` `    ``double` `degree = 30;` `    ``double` `radian = Convert(degree);` `    ``cout << radian;` `    ``return` `0;` `}`

## Java

 `// Java program to convert degree to radian` `import` `java.io.*; ` `import` `java.util.*; `   `class` `GFG { ` `    `  `// Function for conversion` `static` `double` `Convert(``double` `degree)` `{` `    ``double` `pi = ``3.14159265359``;` `    `  `    ``return` `(degree * (pi / ``180``));` `}`   `// Driver code` `public` `static` `void` `main(String[] args) ` `{ ` `    ``double` `degree = ``30``;` `    ``double` `radian = Convert(degree);` `    `  `    ``System.out.printf(``"%.6f"``, radian);` `} ` `} `   `// This code is contributed by coder001    `

## Python3

 `# Python3 program to convert degree to radian`   `# Function for conversion` `def` `Convert(degree):`   `    ``pi ``=` `3.14159265359``;` `    ``return` `(degree ``*` `(pi ``/` `180``));`   `# Driver code` `degree ``=` `30``;` `radian ``=` `Convert(degree);` `print``(radian);`   `# This code is contributed by Code_Mech`

## C#

 `// C# program to convert degree to radian` `using` `System;`   `class` `GFG{ ` `    `  `// Function for conversion` `static` `double` `Convert(``double` `degree)` `{` `    ``double` `pi = 3.14159265359;` `    `  `    ``return` `(degree * (pi / 180));` `}`   `// Driver code` `public` `static` `void` `Main() ` `{ ` `    ``double` `degree = 30;` `    ``double` `radian = Convert(degree);` `    `  `    ``Console.Write(``"{0:F6}"``, radian);` `} ` `} `   `// This code is contributed by Code_Mech`

## Javascript

 ``

Output

```0.523599

```

Time Complexity: O(1), as we are not using any loops.
Auxiliary Space: O(1), as we are not using any extra space.

Approach 2: Use the math module

`The math module in Python provides a function called radians(), which takes an angle in degrees and returns the corresponding angle in radians.`

Code implementation for the above approach:

## C++

 `#include ` `#include `   `int` `main()` `{` `    ``int` `degree = 45;` `    ``double` `radian = M_PI * degree / 180.0;` `    ``std::cout << radian << std::endl;` `    ``return` `0;` `}`

## Java

 `public` `class` `Main {` `    ``public` `static` `void` `main(String[] args) {` `        ``int` `degree = ``45``;` `        ``double` `radian = Math.PI * degree / ``180.0``;` `        ``System.out.println(radian);` `    ``}` `}`

## Python

 `# code` `import` `math` `degree ``=` `45` `radian ``=` `math.radians(degree)` `print``(radian)`

## C#

 `// C# Code` `using` `System;`   `class` `Program` `{` `    ``static` `void` `Main(``string``[] args)` `    ``{` `        ``int` `degree = 45;` `        ``double` `radian = Math.PI * degree / 180.0;` `        ``Console.WriteLine(radian);` `    ``}` `}`

## Javascript

 `const degree = 45;` `const radian = degree * (Math.PI / 180);` `console.log(radian);`

Output:

`0.785398`

Time Complexity: O(1)
Auxiliary Space: O(1)

Previous
Next