07/02/2023

C Program to Convert Celsius to Fahrenheit And Vice Versa

Write a C program to convert Celsius to Fahrenheit and Vice Versa. Fahrenheit to Celsius formula and Celsius to Fahrenheit formula. F to C Program in C. Converting the Temperature of Celsius to Fahrenheit, we are using a given Formula. We have just taken a value or temperature in Celsius or Fahrenheit by the user and put the values in the given formula and print the outcome given by the formula on screen.

C Program to Convert Celsius to Fahrenheit And Vice Versa

Here in this problem we are giving three option to the user and the user have to choose. the first choices Celsius To Fahrenheit, the second choice is Fahrenheit To Celsius and the Last one is Exit without testing any one of the queries.

Celsius to Fahrenheit Formula in C

Fahrenheit = ( Celsius * 9 / 5 ) + 32;

Fahrenheit to Celsius Formula in C

Celsius = ( Fahrenheit - 32 ) * 5 / 9;

Read: You can also check this program in C++ Click C++ Program For Converting Temperature Celsius Into Fahrenheit

C Program to Convert Celsius to Fahrenheit And Vice Versa


#include<stdio.h>

main() {
    /* Visit - www.programmingwithbasics.com*/

    float a, b, celsius, fahrenheit;
    int x;
    printf("Press 1 For Convert Fahrenheit To Celsius\n");
    printf("Press 2 For Convert Celsius To Fahrenheit\n");
    printf("\nEnter Your Choice: ");

    scanf("%d", & x);

    switch (x) {
    case 1:
        printf("\nEnter The Temperature in Fahrenheit: ");
        scanf("%f", & a);
        celsius = 5 * (a - 32) / 9;
        printf("\n\nCelsius Temperature is: %f ", celsius);
        break;
    case 2:
        printf("\nEnter The Temperature in Celsius: ");
        scanf("%f", & b);
        fahrenheit = ((9 * b) / 5) + 32;
        printf("\n\nFahrenheit Temperature is: %f ", fahrenheit);
        break;
    default:
        printf("\n\nWrong Choice.....Try Again!!!\n");
    }
    return (0);
}

Convert Celsius to Fahrenheit Output


Convert Celsius to Fahrenheit in C and Vice Versa

Similar to Convert Celsius to Fahrenheit


Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me

0 Comments: