Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int menu;
- float temp_c, temp_f;
- printf("Esse programa pode fazer o seguinte:\n"
- "1. Converter de Fahrenheit para Celsius\n"
- "2. Converter de Celsius para Fahrenheit\n"
- "Insira a opcao desejada (1 ou 2): ");
- scanf("%d", &menu);
- while( menu > 2){
- printf("\nO numero inserido e invalido. Insira novamente: ");
- scanf("%d", &menu);
- }
- while( menu < 1){
- printf("\nO numero inserido e invalido. Insira novamente: ");
- scanf("%d", &menu);
- }
- if( menu == 1 )
- {
- printf("\nDigite a temperatura em Fahrenheit. Ou -461 para encerrar o programa: ");
- scanf ("%f", &temp_f);
- if( temp_f <= -461 )
- system("pause");
- else
- {
- if(temp_f > -461)
- {
- temp_c = (temp_f - 32)/1.8;
- printf("\nA temperatura correspondente a %.2f graus Fahrenheit e: %.2f", temp_f, temp_c);
- printf("\n");
- }
- }
- }
- else
- {
- printf("\nDigite a temperatura em Celsius. Ou -274 para encerrar o programa: ");
- scanf ("%c", &temp_c);
- if( temp_c <= -274)
- system("pause");
- else
- {
- if( temp_c > -274)
- {
- temp_f = (temp_c*1.8) + 32;
- printf("\nA temperatura correspondente a %.2f graus Celsius e: %.2f", temp_c, temp_f);
- printf("\n");
- }
- }
- }
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement