Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #ifndef M_PI
- #define M_PI 3.14159265358979323846
- #endif
- double toDegrees(double dAngleRadians) {
- return dAngleRadians * 180.0 / M_PI;
- }
- double toRadians(double dAngleDegrees) {
- return dAngleDegrees * M_PI / 180.0;
- }
- int main (int argc, char **argv){
- double dDegrees, dRadians;
- dDegrees = 90.0;
- printf("Degrees: %f\n",dDegrees);
- dRadians = toRadians(dDegrees);
- printf("Radians: %f\n",dRadians);
- dDegrees = toDegrees(dRadians);
- printf("Degrees: %f\n",dDegrees);
- return 0;
- }
- /*
- output:
- Degrees: 90.000000
- Radians: 1.570796
- Degrees: 90.000000
- */
Advertisement
Add Comment
Please, Sign In to add comment