Convert degree to radian

Here given code implementation process.

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

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

Output

Degree : 1.000000 Radian : 0.017453
Degree : 7.800000 Radian : 0.136136
Degree : 167.500000 Radian : 2.923426
/*
  Java program
  Convert degree to radian
*/
class MyMath
{
  //Find the radian of given degree
  public void degree_to_radian(double degree)
  {
    // Convert given degree to radian
    // Formula : degree * (π / 180);
    double radians = degree * (Math.PI / 180);
    //Display result
    System.out.print("Degree : " + degree + " Radian : " + radians + "\n");
  }
  public static void main(String[] args)
  {
    MyMath obj = new MyMath();
    //Simple test
    obj.degree_to_radian(1);
    obj.degree_to_radian(7.8);
    obj.degree_to_radian(167.5);
  }
}

Output

Degree : 1.0 Radian : 0.017453292519943295
Degree : 7.8 Radian : 0.1361356816555577
Degree : 167.5 Radian : 2.923426497090502
/*
  C++ program
  Convert degree to radian
*/
#include<iostream>
#include<math.h>

using namespace std;
class MyMath
{
  public:
    //Find the radian of given degree
    void degree_to_radian(double degree)
    {
      // Convert given degree to radian
      // Formula : degree * (π / 180);
      double radians = degree * (M_PI / 180);
      //Display result
      cout << "Degree : " << degree << " Radian : " << radians << "\n";
    }
};
int main()
{
  MyMath obj =  MyMath();
  //Simple test
  obj.degree_to_radian(1);
  obj.degree_to_radian(7.8);
  obj.degree_to_radian(167.5);
  return 0;
}

Output

Degree : 1 Radian : 0.0174533
Degree : 7.8 Radian : 0.136136
Degree : 167.5 Radian : 2.92343
/*
  C# program
  Convert degree to radian
*/
using System;
class MyMath
{
  //Find the radian of given degree
  public void degree_to_radian(double degree)
  {
    // Convert given degree to radian
    // Formula : degree * (π / 180);
    double radians = degree * (Math.PI / 180);
    //Display result
    Console.Write("Degree : " + degree + " Radian : " + radians + "\n");
  }
  public static void Main(String[] args)
  {
    MyMath obj = new MyMath();
    //Simple test
    obj.degree_to_radian(1);
    obj.degree_to_radian(7.8);
    obj.degree_to_radian(167.5);
  }
}

Output

Degree : 1 Radian : 0.0174532925199433
Degree : 7.8 Radian : 0.136135681655558
Degree : 167.5 Radian : 2.9234264970905
<?php
/*
  Php program
  Convert degree to radian
*/
class MyMath
{
  //Find the radian of given degree
  public  function degree_to_radian($degree)
  {
    // Convert given degree to radian
    // Formula : degree * (π / 180);
    $radians = $degree * (M_PI / 180);
    echo "Degree : ". $degree ." Radian : ". $radians ."\n";
  }
}

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

Output

Degree : 1 Radian : 0.017453292519943
Degree : 7.8 Radian : 0.13613568165556
Degree : 167.5 Radian : 2.9234264970905
/*
  Node Js program
  Convert degree to radian
*/
class MyMath
{
  //Find the radian of given degree
  degree_to_radian(degree)
  {
    // Convert given degree to radian
    // Formula : degree * (π / 180);
    var radians = degree * (Math.PI / 180);
    process.stdout.write("Degree : " + degree + " Radian : " + radians + "\n");
  }
}

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

Output

Degree : 1 Radian : 0.017453292519943295
Degree : 7.8 Radian : 0.1361356816555577
Degree : 167.5 Radian : 2.923426497090502
#   Python 3 program
#   Convert degree to radian
import math

class MyMath :
  # Find the radian of given degree
  def degree_to_radian(self, degree) :
    #  Convert given degree to radian
    #  Formula : degree * (π / 180)
    radians = degree * (math.pi / 180)
    print("Degree : ", degree ," Radian : ", radians ,"\n", end = "")
  

def main() :
  obj = MyMath()
  # Simple test
  obj.degree_to_radian(1)
  obj.degree_to_radian(7.8)
  obj.degree_to_radian(167.5)

if __name__ == "__main__": main()

Output

Degree :  1  Radian :  0.017453292519943295
Degree :  7.8  Radian :  0.1361356816555577
Degree :  167.5  Radian :  2.923426497090502
#   Ruby program
#   Convert degree to radian

class MyMath

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

  obj = MyMath.new()
  # Simple test
  obj.degree_to_radian(1)
  obj.degree_to_radian(7.8)
  obj.degree_to_radian(167.5)
end
main()

Output

Degree : 1 Radian : 0.017453292519943295
Degree : 7.8 Radian : 0.1361356816555577
Degree : 167.5 Radian : 2.923426497090502
/*
  Scala program
  Convert degree to radian
*/
class MyMath
{
  //Find the radian of given degree
  def degree_to_radian(degree: Double): Unit = {
    // Convert given degree to radian
    // Formula : degree * (π / 180);
    var radians: Double = degree * (Math.PI / 180);
    //Display result
    print("Degree : " + degree + " Radian : " + radians + "\n");
  }
}
object Main
{
  def main(args: Array[String]): Unit = {
    var obj: MyMath = new MyMath();
    //Simple test
    obj.degree_to_radian(1);
    obj.degree_to_radian(7.8);
    obj.degree_to_radian(167.5);
  }
}

Output

Degree : 1.0 Radian : 0.017453292519943295
Degree : 7.8 Radian : 0.1361356816555577
Degree : 167.5 Radian : 2.923426497090502
/*
  Swift program
  Convert degree to radian
*/
import Foundation
class MyMath
{
  //Find the radian of given degree
  func degree_to_radian(_ degree: Double)
  {
    // Convert given degree to radian
    // Formula : degree * (π / 180);
    let radians: Double = Double(degree) * (Double.pi / 180);
    print("Degree : ", degree ," Radian : ", radians ,"\n", terminator: "");
  }
}
func main()
{
  let obj: MyMath = MyMath();
  //Simple test
  obj.degree_to_radian(1);
  obj.degree_to_radian(7.8);
  obj.degree_to_radian(167.5);
}
main();

Output

Degree :  1.0  Radian :  0.0174532925199433
Degree :  7.8  Radian :  0.136135681655558
Degree :  167.5  Radian :  2.9234264970905


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