Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- main()
- {
- int op,i;
- float cel[2],fah[2],kel[2],Result[6];
- for(i=0; op != 0; i++)
- {
- printf("\n-> ~~~~~~~~~~~~~~~~ Conversor de Temperatura ~~~~~~~~~~~~~~~~~ <-\n");
- printf("\n");
- printf("1 - Celsius para Fahrenheit\n");
- printf("2 - Celsius para Kelvin\n");
- printf("\n");
- printf("3 - Fahrenheit para Celsius\n");
- printf("4 - Fahrenheit para Kelvin\n");
- printf("\n");
- printf("5 - Kelvin para Celsius\n");
- printf("6 - Kelvin para Fahrenheit\n");
- printf("\n");
- printf("0 - Para sair\n");
- printf("Escolha qual das conversoes desejas fazer:");
- scanf("%d",&op);
- system("CLS");
- if(op > 6)
- {
- printf("(ERRO) Numero invalido!");
- }
- switch(op)
- {
- system("CLS");
- case 1:
- {
- printf("Digite o numero de graus Celsius:");
- scanf("%f",&cel[0]);
- Result[0] = ((cel[0] *1.8) + 32);
- printf("Resultado: %0.3f graus Fahrenheit\n",Result[0]);
- break;
- }
- case 2:
- {
- printf("Digite o numero de graus Celsius:");
- scanf("%f",&cel[1]);
- Result[1] = cel[1] + 273.15;
- printf("Resultado: %0.3f Kelvin",Result[1]);
- break;
- }
- case 3:
- {
- printf("Digite um numero de graus Fahrenheit:");
- scanf("%f",&fah[0]);
- Result[2] = (fah[0] - 32) / 1.8;
- printf("Resultado: %0.3f Celsius",Result[2]);
- break;
- }
- case 4:
- {
- printf("Digite um numero de graus Fahrenheit:");
- scanf("%f",&fah[1]);
- Result[3] = ((fah[1] + 459.67) / 1.8);
- printf("Resultado: %0.3f Kelvin",Result[3]);
- break;
- }
- case 5:
- {
- printf("Digite um numero na escala Kelvin:");
- scanf("%f",&kel[0]);
- Result[4] = kel[0] - 273.15;
- printf("Resultado: %0.3f graus Celsius",Result[4]);
- break;
- }
- case 6:
- {
- printf("Digite um numero na escala Kelvin:");
- scanf("%f",&kel[1]);
- Result[5] = ((kel[1] * 1.8) - 459.67);
- printf("Resultado: %0.3f Fahrenheit.",Result[5]);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement