Subscribe Our Telegram Channel Join Now!

06. How To Write a C program to convert temperature from Fahrenheit to Celsius and vice versa

Convert Fahrenheit to Celsius in C

C program to convert temperature from Fahrenheit to Celsius and vice versa. Let's Go.

Source Code:

Code 

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

#include 
int main()
{
    float cl, fh;
    int choice;

    printf("1. Fahrenheit to Celsius\n");
    printf("2. Celsius to Fahrenheit\n");
    printf("Enter your choice: \n");
    scanf("%d", &choice);

    switch (choice)
    {
    case 1:
        printf("Enter your temperature in Fahrenheit: ");
        scanf("%f", &fh);
        cl = ((fh - 32) * 5) / 9;
        printf("Your temperature in Celsius: %.2f", cl);
        break;
    case 2:
        printf("Enter your temperature in Celsius: ");
        scanf("%f", &cl);
        fh = (cl * 1.8) + 32;
        printf("Your temperature in Fahrenheit: %.2f", fh);
        break;
    default:
        printf("Invalid Input");
        break;
    }

    return 0;
}



Youtube Video:


Get this Code on  Github


Getting Info...

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.