Advertisement
paulogp

Conversão radianos - graus

Jul 13th, 2011
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. // Apple Xcode
  2. // Conversão de um número em radianos e vice-versa
  3.  
  4.  
  5. #include <stdio.h>
  6.  
  7. #define PI 3.1416
  8.  
  9.  
  10. int main (int argc, const char * argv[])
  11. {
  12.     int the_option;
  13.     float the_value = 0.00;
  14.     float the_result = 0.00;
  15.  
  16.     printf("insira o valor: ");
  17.     scanf("%f", &the_value);
  18.  
  19.     printf("\n");
  20.     printf("1: graus->rad\n");
  21.     printf("2: rad -> graus\n");
  22.     scanf("%i", &the_option);
  23.  
  24.     switch(the_option) {
  25.         case 1:
  26.             the_result = the_value * PI / 180;
  27.             printf("radianos: %f\n", the_result);
  28.             break;
  29.         case 2:
  30.             the_result = the_value * 180 / PI;
  31.             printf("graus: %f\n", the_result);
  32.             break;
  33.         default:
  34.             printf("opcao invalida!\n");
  35.     }
  36.  
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement