Program to Convert Radian to Degree
Last Updated :
30 Mar, 2023
Before moving to the actual solution, let's try to find out what is a degree, a radian, and their relations.
Radian: The radian is the standard unit of angular measure, used in many areas of mathematics. The length of an arc of a unit circle is numerically equal to the measurement in radians of the angle that it subtends. One radian is just under 57.3 degrees.
Degree: A degree (in full, a degree of arc, arc degree, or arcdegree), usually denoted by ° (the degree symbol), is a measurement of a plane angle, defined so that a full rotation is 360 degrees.
The relation 2pi*rad = 360° can be derived using the formula for arc length.
An arc of a circle with the same length as the radius of that circle subtends an angle of 1 radian. The circumference subtends an angle of 2pi radians.
Therefore the formula is:
degree = radian * (180/pi)
where, pi = 22/7
Examples:
Input : radian = 20
Output : degree = 1145.4545454545455
Explanation: degree = 20 * (180/pi)
Input : radian = 5
Output : degree = 286.3636363636364
Explanation : degree = 5 * (180/pi)
Note: In this programs, we have taken the value of pi as 3.14159 to get standard result in all three languages.
C++
// C++ code to convert radian to degree
#include <iostream>
using namespace std;
// Function for conversion
double Convert(double radian)
{
double pi = 3.14159;
return(radian * (180 / pi));
}
// Driver code
int main()
{
double radian = 5.0;
double degree = Convert(radian);
cout << degree;
return 0;
}
// This code is contributed by Khushboogoyal499
C
// C code to convert radian to degree
#include <stdio.h>
// Function for conversion
double Convert(double radian){
double pi = 3.14159;
return(radian * (180/pi));
}
// Driver Code
int main(){
double radian = 5.0;
double degree = Convert(radian);
printf("%.5lf", degree);
return 0;
}
Java
// Java code to convert radian to degree
import java.io.*;
class GFG {
// Function for conversion
static double Convert(double radian){
double pi = 3.14159;
return(radian * (180/pi));
}
// Driver Code
public static void main (String[] args) {
double radian = 5.0;
double degree = Convert(radian);
System.out.println("degree = "+ degree);
}
}
Python3
# Python code to convert radian to degree
# Function for conversion
def Convert(radian):
pi = 3.14159
# Simply used the formula
degree = radian * (180/pi)
return degree
# Driver Code
radian = 5
print("degree =",(Convert(radian)))
C#
// C# code to convert radian to degree.
using System;
class GFG {
// Function for conversion
static double Convert(double radian){
double pi = 3.14159;
return(radian * (180 / pi));
}
// Driver Code
public static void Main () {
double radian = 5.0;
double degree = Convert(radian);
Console.Write("degree = " + degree);
}
}
// This code is contributed by Nitin Mittal.
PHP
<?php
// PHP code to convert radian to degree
// Function for conversion
function Convert($radian)
{
$pi = 3.14159;
return($radian * (180 / $pi));
}
// Driver Code
$radian = 5.0;
$degree = Convert($radian);
echo( $degree);
// This code is contributed by nitin mittal
?>
JavaScript
<script>
// Javascript code to convert radian to degree
// Function for conversion
function Convert(radian){
let pi = 3.14159;
return(radian * (180/pi));
}
// Driver Code
let radian = 5.0;
let degree = Convert(radian);
document.write(degree);
// This code is contributed Mayank Tyagi
</script>
Time Complexity: O(1), as we are not using any loops.
Auxiliary Space: O(1), as we are not using any extra space.
Example :
The following program demonstrates toDegree() and toRadians().
C++
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double theta = 120.0;
// degree --> radians
cout << theta << " degree is " << (theta * M_PI / 180) << " radians." << endl;
theta = 1.312;
// radians --> degrees
cout << theta << " radians is " << (theta * 180 / M_PI) << " degrees." << endl;
return 0;
}
Java
// Demonstrate toDegree and toRadians():
class GFG{
public static void main(String args[]){
double theta = 120.0;
// degree --> radians
System.out.println(theta+ " degree is "+ Math.toRadians(theta)+ " radians.");
theta =1.312;
// radians --> degrees
System.out.println(theta+ " radians is "+ Math.toDegrees(theta)+ " degrees.");
}
}
Python3
# Demonstrate toDegree and toRadians():
import math
theta = 120.0;
#degree --> radians
print(theta, "degree is", math.radians(theta), "radians.");
theta =1.312;
#radians --> degrees
print(theta, "radians is ", math.degrees(theta), "degrees.");
# This code is contributed by phasing17
JavaScript
// Convert degrees to radians
function degreesToRadians(degrees) {
return degrees * Math.PI / 180;
}
// Convert radians to degrees
function radiansToDegrees(radians) {
return radians * 180 / Math.PI;
}
// Example usage
const theta = 120.0;
// degree --> radians
console.log(`${theta} degree is ${degreesToRadians(theta)} radians.`);
const radians = 1.312;
// radians --> degrees
console.log(`${radians} radians is ${radiansToDegrees(radians)} degrees.`);
C#
using System;
class MainClass {
public static void Main(string[] args)
{
double theta = 120.0;
// degree --> radians
Console.WriteLine(theta + " degree is "
+ (theta * Math.PI / 180)
+ " radians.");
theta = 1.312;
// radians --> degrees
Console.WriteLine(theta + " radians is "
+ (theta * 180 / Math.PI)
+ " degrees.");
}
}
Output120.0 degree is 2.0943951023931953 radians.
1.312 radians is 75.17206272116401 degrees.
Time Complexity: O(1), as it is using constant operations
Auxiliary Space: O(1), as it is using constant variables
Reference:
https://en.wikipedia.org/wiki/Radian
https://en.wikipedia.org/wiki/Degree_(angle)
Similar Reads
Program to convert Degree to Radian 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 circl
3 min read
Program to convert temperature from degree Celsius to Kelvin Given temperature in degree Celsius, convert it into to Kelvin . Examples: Input : C = 100 Output : k = 373.15 Input : C = 110 Output : k = 383.15 Formula for converting temperature in degree Celsius to kelvin- K = ( °C + 273.15 ) 0 °C = 273.15 kelvin Below is the program for temperature conversion:
3 min read
Program for Celsius To Fahrenheit conversion Given a Temperature N on the Celsius scale, your task is to convert it into a Fahrenheit scale. Examples: Input: 0Output: 32 Input: -40Output: -40 Recommended PracticeCelsius to Fahrenheit ConversionTry It! The formula for converting the Celsius scale to the Fahrenheit scale is: T(°F) = T(°C) à 9/5
3 min read
Program for Fahrenheit to Celsius conversion Given a Temperature n in Fahrenheit scale convert it into Celsius scale .Examples: Input : 32 Output : 0 Input :- 40 Output : -40 Formula for converting Fahrenheit scale to Celsius scale T(°C) = (T(°F) - 32) à 5/9 C /* Program in C to convert Degree Fahrenheit to Degree Celsius */ #include <stdio
3 min read
Program to convert polar co-ordinates to equivalent cartesian co-ordinates Given two integers r and \theta(in degree) representing polar coordinates of a point (r, \theta), the task is to find the Cartesian coordinates of the given point.Examples:Input: r = 1.4142, \theta = 45Output: 1.000, 1.000Input: r = 3, \theta = 30Output: 2.598, 1.500Approach: Let the cartesian coord
4 min read
Program to find Circumference of a Circle Given radius of a circle, write a program to find its circumference.Examples : Input : 2 Output : Circumference = 12.566 Input : 8 Output : Circumference = 50.264 In a circle, points lie in the boundary of a circle are at same distance from its center. This distance is called radius. Circumference o
3 min read