61 total views

The program – “C++ Program to Convert Radian to Degree” is based on a simple mathematical concept. The degree is converted to radian value or radian is converted to degrees for computing trigonometric identities.

In this program, we used two formulas for following

- Radian to Degree conversion
- Degree to Radian conversion

This program – C++ Program to Convert Radian to Degree is intended for beginners of C++ programming language and we used Dev C++ 4.9.9.2 compiler to compile and run this program. However, you can use any other standard C++ compiler to compile and execute the program.

To help you learn, go through each section given below,

- Problem definition
- Flowchart
- Program code
- Output

Contents

## Problem Definition

In this C++ program, the user makes one of the two choices – perform radian to degree conversion or degree to radian conversion. Since, this program is based simple math, we used formulas given below.

Converting from radian to degree

The formula to convert radians to degree is

`Degree = radian * 180/π`

Converting from degrees to radians

`radian = degree * π/180`

When a user start the program, the C++ program does following.

- Ask to choose a conversion method
- Ask input values based on the conversion chosen by the user.
- Use formula for conversion
- Print the output value.

See the flowchart section for logical flow of the program.

## Flowchart – Radian to Degree Program

## Program Code – Radian to Degree Program

```
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main()
{
float radian, degree, pi;
int choice;
pi = 3.14;
// Menu
cout << "1.Radian to Degree" << endl;
cout << "2.Degree to Raidan" << endl;
cout << "\n\n";
cout << "Enter Your Choice:”; cin >> choice;
// Switch starts here
switch (choice)
{
Case 1:
cout << "Enter Radian Value to Convert: ";
cin << radian;
cout << "\n\n";
degree = radian * 180/pi;
cout << "The Degree Value for" << " "
<< radian << " " << "radian is" << " "
<< degree << " " << "degree" << " " << endl;
break;
Case 2:
cout << "Enter Degree Value to Convert:";
cin << degree;
cout << "\n\n";
radian = degree * pi/180;
cout << "The Radian Value for" << " "
<< degree << " " << "degree is" << " "
<< radian << "radian" << " " << endl;
break;
default:
cout << "Wrong Value! Try again later" << endl;
}
system ("pause");
return EXIT_SUCCESS;
}
```

## Output

The output of the above program is given below. When a user enters the radian measure(0.785) the corresponding degree value is computed and displayed on the console.