C Program To Convert Celsius To Fahrenheit

In this program, we will learn how to convert Celsius to Fahrenheit using C Programming language.

C Program To Convert Celsius To Fahrenheit

To convert degree Celsius into degree Fahrenheit, we have to follow these steps: 

  1. Multiply the degree Celsius by 9/5 or 1.8
  2. Then Add 32 to this Number. This is the answer in degree Fahrenheit

We will be using the same approach in our program to convert Celsius to Fahrenheit.

So, without further ado, let’s begin this tutorial.

C Program To Convert Celsius To Fahrenheit

// C Program To Convert Celsius To Fahrenheit
#include <stdio.h>
int main(){
    float celsius, fahrenheit;
    
    // Asking for input
    printf("Enter temperature in Celsius: ");
    scanf("%f", &celsius);
    
    fahrenheit = (celsius * 9 / 5) + 32;
    printf("%.2f in Celsius = %.2f in Fahrenheit", celsius, fahrenheit);
    return 0;
}

Output

Enter temperature in Celsius: 37.6
37.60 in Celsius = 99.68 in Fahrenheit

How Does This Program Work ?

    float celsius, fahrenheit;

In this program, we have declared two float data type variables named celsius and fahrenheit.

    // Asking for input
    printf("Enter temperature in Celsius: ");
    scanf("%f", &celsius);

Then, the user is asked to enter the temperature in degree Celsius.

    fahrenheit = (celsius * 9 / 5) + 32;

Now, we convert the temperature into degree Fahrenheit by using the formula – [(degree in Celsius * 9 / 5) + 32].

    printf("%.2f in Celsius = %.2f in Fahrenheit", celsius, fahrenheit);

Finally, we print the result using printf() function. Here, we have used %.2f format specifier because we want to display the result only till 2 decimal places.

Conclusion

I hope after going through this post, you understand how to convert Celsius to Fahrenheit in C Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.

Also Read:

Leave a Comment

Your email address will not be published. Required fields are marked *