Convert Degree Celsius To Fahrenheit: C Program


Temperature of a city in Degree Celsius / Centigrade degree is input through the keyboard. Write a program to convert this temperature into Fahrenheit.

Related Read:
Basic Arithmetic Operations In C
Division of 2 Numbers: C
Convert Fahrenheit To Degree Celsius: C Program

Formula to Convert Celsius To Fahrenheit

Fahrenheit = (Centigrade * (9/5)) + 32;
But in C programming, any number divided by an integer number will return integer value. So 9/5 will give 1 and not 1.8

So we need to be careful while doing division operation in C. To solve this issue we can write following formula in C program to convert degree celsius to Fahrenheit.

Fahrenheit = (Centigrade * (9/5.0)) + 32;
OR
Fahrenheit = (Centigrade * 1.8) + 32;

Convert Degree Celsius To Fahrenheit: C Program



YouTube Link: https://www.youtube.com/watch?v=UFtA-OVypHs [Watch the Video In Full Screen.]


Source Code: Convert Degree Celsius To Fahrenheit: C Program

  1. #include < stdio.h >  
  2.   
  3. int main()  
  4. {  
  5.     float c, fh;  
  6.   
  7.     printf("Enter temperature in Centigrade\n");  
  8.     scanf("%f", &c);  
  9.   
  10.     fh = (c * 1.8) + 32;  
  11.   
  12.     printf("Temperature in Fahrenheit is %f\n", fh);  
  13.   
  14.     return 0;  
  15. }  

Output 1:
Enter temperature in Centigrade
100
Temperature in Fahrenheit is 212.000000

Output 2:
Enter temperature in Centigrade
45
Temperature in Fahrenheit is 113.000000

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert

Leave a Reply

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