C program to convert temperature from degree Fahrenheit to Celsius

Write a C program to input temperature in degree Fahrenheit and convert it to degree Centigrade. How to convert temperature from degree Fahrenheit to degree Celsius in C programming. C program for temperature conversion. 


Example:
Input temperature in Fahrenheit = 205
Output = 96.11 C

Required knowledge:

Fundamentals of CData typesTaking user input in CTemperature conversion table 

Conversion formula 

°C = (°F -32) * 5/9 

Program

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
 * C program to convert temperature from degree Fahrenheit to Celsius
 */
 
#include <stdio.h>
 
void main()
{
    float celsius, fahrenheit;
 
    // Reads temperature in Fahrenheit from user
    printf("Enter temperature in Fahrenheit: ");
    scanf("%f", &fahrenheit);
 
    // Converts fahrenheit to celsius
    celsius = (fahrenheit-32) * 5/9;
 
    printf("\n%.2f Fahrenheit = %.2f Celsius", fahrenheit, celsius);
 
 
}

Note: %.2f is used to print fractional values only up to two decimal places. You can also use %f to print fractional values normally up to six decimal places.

Output
X
_
Enter temperature in Fahrenheit: 205

205.00 Fahrenheit = 96.11 Celsius

Enjoy it....................

Comments

Popular posts from this blog

C program to calculate velocity

C program to find square root of a number

C program to find maximum between two numbers