moranguinho

exer7ES1

Mar 13th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. /*Escreva um algoritmo que converta um valor temperatura de graus Fahrenheit para
  2. graus Celsius, cuja fórmula de conversão é: (graus Fahrenheit - 32) * (5/9). Faça o teste
  3. de mesa para 5 valores verificando se o algoritmo está correto. Primeiro calcule ou
  4. procure ou calcule o valor de saída esperado. Use a seguinte tabela para o teste de mesa. */
  5. #include <stdio.h>
  6. int main(void)
  7. {
  8. float fahr, celsius;
  9. printf("temperatura em Fahrenheit: ");
  10. scanf("%f", &fahr);
  11.  
  12. celsius = (fahr - 32) * ((float)5/9); // Pra divisão nao dar um numero inteiro ou por (float) grudado no nº ou por .0 em um deles
  13.  
  14. printf("%.2f graus Fahreinheit correspondem a %.2f graus Celsius: \n", fahr, celsius);
  15. }
  16. // LEMBRAR DE CORRIGIR ONDE EU COLOCO OS PARENTESES!!!!!!!!!!!!!!
Advertisement
Add Comment
Please, Sign In to add comment