Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main() {
  5. int menu;
  6. float temp_c, temp_f;
  7.  
  8. printf("Esse programa pode fazer o seguinte:\n"
  9. "1. Converter de Fahrenheit para Celsius\n"
  10. "2. Converter de Celsius para Fahrenheit\n"
  11. "Insira a opcao desejada (1 ou 2): ");
  12. scanf("%d", &menu);
  13.  
  14. while( menu > 2){
  15. printf("\nO numero inserido e invalido. Insira novamente: ");
  16. scanf("%d", &menu);
  17. }
  18.  
  19. while( menu < 1){
  20. printf("\nO numero inserido e invalido. Insira novamente: ");
  21. scanf("%d", &menu);
  22. }
  23.  
  24. if( menu == 1 )
  25. {
  26. printf("\nDigite a temperatura em Fahrenheit. Ou -461 para encerrar o programa: ");
  27. scanf ("%f", &temp_f);
  28.  
  29. if( temp_f <= -461 )
  30. system("pause");
  31. else
  32. {
  33. if(temp_f > -461)
  34. {
  35. temp_c = (temp_f - 32)/1.8;
  36. printf("\nA temperatura correspondente a %.2f graus Fahrenheit e: %.2f", temp_f, temp_c);
  37. printf("\n");
  38. }
  39. }
  40. }
  41.  
  42. else
  43. {
  44. printf("\nDigite a temperatura em Celsius. Ou -274 para encerrar o programa: ");
  45. scanf ("%c", &temp_c);
  46.  
  47. if( temp_c <= -274)
  48. system("pause");
  49. else
  50. {
  51. if( temp_c > -274)
  52. {
  53. temp_f = (temp_c*1.8) + 32;
  54. printf("\nA temperatura correspondente a %.2f graus Celsius e: %.2f", temp_c, temp_f);
  55. printf("\n");
  56. }
  57. }
  58. }
  59.  
  60. system("pause");
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement