Convert radian to degree

Here given code implementation process.

//C Program 
//Convert radian to degree 
#include <stdio.h>

#include <math.h>

//Find the degree of given radian
void radian_to_degree(double radian)
{
	// Formula : (radian*180)/π
	// Calculate given radian to degree 
	double degree = (radian * 180) / M_PI;
	//Display result
	printf("Radian : %lf  Degree : %lf\n", radian, degree);
}
int main()
{
	//Simple test
	radian_to_degree(1);
	radian_to_degree(7.8);
	radian_to_degree(10.5);
	return 0;
}

Output

Radian : 1.000000  Degree : 57.295780
Radian : 7.800000  Degree : 446.907080
Radian : 10.500000  Degree : 601.605685
/*
  Java program
  Convert radian to degree 
*/
class MyMath
{
	//Find the degree of given radian
	public void radian_to_degree(double radian)
	{
		// Formula : (radian*180)/π
		// Calculate given radian to degree 
		double degree = (radian * 180) / Math.PI;
		System.out.print("Radian : " + radian + " Degree : " + degree + "\n");
	}
	public static void main(String[] args)
	{
		MyMath obj = new MyMath();
		//Simple test
		obj.radian_to_degree(1);
		obj.radian_to_degree(7.8);
		obj.radian_to_degree(10.5);
	}
}

Output

Radian : 1.0 Degree : 57.29577951308232
Radian : 7.8 Degree : 446.9070802020421
Radian : 10.5 Degree : 601.6056848873644
/*
  C++ program
  Convert radian to degree 
*/
#include<iostream>
#include<math.h>
using namespace std;
class MyMath
{
	public:
		//Find the degree of given radian
		void radian_to_degree(double radian)
		{
			// Formula : (radian*180)/π
			// Calculate given radian to degree 
			double degree = (radian * 180) / M_PI;
			cout << "Radian : " << radian << " Degree : " << degree << "\n";
		}
};
int main()
{
	MyMath obj = MyMath();
	//Simple test
	obj.radian_to_degree(1);
	obj.radian_to_degree(7.8);
	obj.radian_to_degree(10.5);
	return 0;
}

Output

Radian : 1 Degree : 57.2958
Radian : 7.8 Degree : 446.907
Radian : 10.5 Degree : 601.606
/*
  C# program
  Convert radian to degree 
*/
using System;
class MyMath
{
	//Find the degree of given radian
	public void radian_to_degree(double radian)
	{
		// Formula : (radian*180)/π
		// Calculate given radian to degree 
		double degree = (radian * 180) / Math.PI;
		Console.Write("Radian : " + radian + " Degree : " + degree + "\n");
	}
	public static void Main(String[] args)
	{
		MyMath obj = new MyMath();
		//Simple test
		obj.radian_to_degree(1);
		obj.radian_to_degree(7.8);
		obj.radian_to_degree(10.5);
	}
}

Output

Radian : 1 Degree : 57.2957795130823
Radian : 7.8 Degree : 446.907080202042
Radian : 10.5 Degree : 601.605684887364
<?php
/*
  Php program
  Convert radian to degree 
*/
class MyMath
{
	//Find the degree of given radian
	public	function radian_to_degree($radian)
	{
		// Formula : (radian*180)/π
		// Calculate given radian to degree 
		$degree = ($radian * 180) / M_PI;
		echo "Radian : ". $radian ." Degree : ". $degree ."\n";
	}
}

function main()
{
	$obj = new MyMath();
	//Simple test
	$obj->radian_to_degree(1);
	$obj->radian_to_degree(7.8);
	$obj->radian_to_degree(10.5);
}
main();

Output

Radian : 1 Degree : 57.295779513082
Radian : 7.8 Degree : 446.90708020204
Radian : 10.5 Degree : 601.60568488736
/*
  Node Js program
  Convert radian to degree 
*/
class MyMath
{
	//Find the degree of given radian
	radian_to_degree(radian)
	{
		// Formula : (radian*180)/π
		// Calculate given radian to degree 
		var degree = (radian * 180) / Math.PI;
		process.stdout.write("Radian : " + radian + " Degree : " + degree + "\n");
	}
}

function main()
{
	var obj = new MyMath();
	//Simple test
	obj.radian_to_degree(1);
	obj.radian_to_degree(7.8);
	obj.radian_to_degree(10.5);
}
main();

Output

Radian : 1 Degree : 57.29577951308232
Radian : 7.8 Degree : 446.9070802020421
Radian : 10.5 Degree : 601.6056848873644
#   Python 3 program
#   Convert radian to degree 
import math
class MyMath :
	# Find the degree of given radian
	def radian_to_degree(self, radian) :
		#  Formula : (radian*180)/π
		#  Calculate given radian to degree 
		degree = (radian * 180) / math.pi
		print("Radian : ", radian ," Degree : ", degree ,"\n", end = "")
	

def main() :
	obj = MyMath()
	# Simple test
	obj.radian_to_degree(1)
	obj.radian_to_degree(7.8)
	obj.radian_to_degree(10.5)

if __name__ == "__main__": main()

Output

Radian :  1  Degree :  57.29577951308232
Radian :  7.8  Degree :  446.9070802020421
Radian :  10.5  Degree :  601.6056848873644
#   Ruby program
#   Convert radian to degree 

class MyMath

	# Find the degree of given radian
	def radian_to_degree(radian)
	
		#  Formula : (radian*180)/π
		#  Calculate given radian to degree 
		degree = (radian * 180) / Math::PI
		print("Radian : ", radian ," Degree : ", degree ,"\n")
	end
end
def main()

	obj = MyMath.new()
	# Simple test
	obj.radian_to_degree(1)
	obj.radian_to_degree(7.8)
	obj.radian_to_degree(10.5)
end
main()

Output

Radian : 1 Degree : 57.29577951308232
Radian : 7.8 Degree : 446.9070802020421
Radian : 10.5 Degree : 601.6056848873644
/*
  Scala program
  Convert radian to degree 
*/
class MyMath
{
	//Find the degree of given radian
	def radian_to_degree(radian: Double): Unit = {
		// Formula : (radian*180)/π
		// Calculate given radian to degree 
		var degree: Double = (radian * 180) / Math.PI;
		print("Radian : " + radian + " Degree : " + degree + "\n");
	}
}
object Main
{
	def main(args: Array[String]): Unit = {
		var obj: MyMath = new MyMath();
		//Simple test
		obj.radian_to_degree(1);
		obj.radian_to_degree(7.8);
		obj.radian_to_degree(10.5);
	}
}

Output

Radian : 1.0 Degree : 57.29577951308232
Radian : 7.8 Degree : 446.9070802020421
Radian : 10.5 Degree : 601.6056848873644
/*
  Swift program
  Convert radian to degree 
*/
import Foundation
class MyMath
{
	//Find the degree of given radian
	func radian_to_degree(_ radian: Double)
	{
		// Formula : (radian*180)/π
		// Calculate given radian to degree 
		let degree: Double = (radian * 180) / Double.pi;
		print("Radian : ", radian ," Degree : ", degree ,"\n", terminator: "");
	}
}
func main()
{
	let obj: MyMath = MyMath();
	//Simple test
	obj.radian_to_degree(1);
	obj.radian_to_degree(7.8);
	obj.radian_to_degree(10.5);
}
main();

Output

Radian :  1.0  Degree :  57.2957795130823
Radian :  7.8  Degree :  446.907080202042
Radian :  10.5  Degree :  601.605684887364


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment







© 2021, kalkicode.com, All rights reserved