RicardasSim

radians degrees

Feb 20th, 2019
583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. #ifndef M_PI
  6. #define M_PI 3.14159265358979323846
  7. #endif
  8.  
  9. double toDegrees(double dAngleRadians) {
  10.     return dAngleRadians * 180.0 / M_PI;
  11. }
  12.  
  13. double toRadians(double dAngleDegrees) {
  14.     return dAngleDegrees * M_PI / 180.0;
  15. }
  16.  
  17. int main (int argc, char **argv){
  18.  
  19.  
  20.     double dDegrees, dRadians;
  21.    
  22.     dDegrees = 90.0;
  23.    
  24.     printf("Degrees: %f\n",dDegrees);
  25.    
  26.     dRadians = toRadians(dDegrees);
  27.    
  28.     printf("Radians: %f\n",dRadians);
  29.    
  30.     dDegrees = toDegrees(dRadians);
  31.    
  32.     printf("Degrees: %f\n",dDegrees);
  33.    
  34. return 0;
  35. }
  36.  
  37. /*
  38. output:
  39.  
  40. Degrees: 90.000000
  41. Radians: 1.570796
  42. Degrees: 90.000000
  43.  
  44. */
Advertisement
Add Comment
Please, Sign In to add comment