Skip to main content

C program to convert temperature from Fahrenheit to Celsius and vice versa.

Program:-


#include <stdio.h>
void main()
{
    float fh,cl;
    int choice;

    printf("1:Convert temperature from Fahrenheit to Celsius.");
    printf("\n2:Convert temperature from Celsius to Fahrenheit.");
    printf("\nEnter your choice (1, 2): ");
    scanf("%d",&choice);

    if(choice ==1)
    {
        printf("Enter temperature in Fahrenheit: ");
        scanf("%f",&fh);
        cl= (fh - 32) / 1.8;
        printf("\nTemperature in Celsius: %.2f",cl);
    }
    else if(choice==2)
    {
        printf("Enter temperature in Celsius: ");
        scanf("%f",&cl);
        fh= (cl*1.8)+32;
        printf("\nTemperature in Fahrenheit: %.2f",fh);
    }
    else
    {
        printf("\nInvalid Choice !!!");
    }
}


OUTPUT :-


OUTPUT 1:

 1:Convert temperature from Fahrenheit to Celsius.

2:Convert temperature from Celsius to Fahrenheit.


Enter your choice (1, 2): 1

Enter temperature in Fahrenheit: 200


Temperature in Celsius: 93.33


OUTPUT 2:

1:Convert temperature from Fahrenheit to Celsius.

2:Convert temperature from Celsius to Fahrenheit.


Enter your choice (1, 2): 2

Enter temperature in Celsius: 200


Temperature in Fahrenheit: 392.00


Program File:(click the following .c file to get the program file)    

                      Temp.c

Comments

Popular posts from this blog

Logical Reasoning.

  Quiz 2:- 2.In a code language QUEEN is written as OVCFL, then KING is written as a. IJLH b. MKOF c. PHIK d. FOKM Answer:-  a. IJLH Explanation: Alphabet Series - A B C D E F G H I J K L M N O P Q R S T U V W X Y Z The coding follows the rule -2, +1, -2, +1, etc. That means Q -2 = O U+1=V E-2=C, etc.

Logical Reasoning

Quiz 4:-   4. If DOOR = 25, LOWER=37, TOWER=18, then OVER = ? a.85 b.60 c.45 d.06 Answer:- d.06 Explanation:- Alphabets and their positions |A|B|C|D|E|F|G|H|I|J| | K|L|M|N|O|P|Q|R| |S|T |U|V|W|X|Y|Z| |1|2 |3|4 |5|6|7 |8|9|10| |11|12|13|14|15|16|17|18| |19|20|21|22|23|24|25|26 | Rule:- Add positions of alphabets and then reverse the result DOOR = 4+15+15+18 = 52 = reverse 52 to give 25 and so on...

Logical Reasoning

  Quiz 7 7. CEGI : JHFD :: KMOQ : ? a. LPNR b. RNPL c. LNPR d. RPNL Answer:  d. RPNL Explanation: Alphabet Series:- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Write the next letters after the letters CEGI. We get DFHJ. Reverse them to get JHFD Next letters after KMOQ is LNPR. Reversing them we get RPNL