C program to convert temperature from degree Celsius to Fahrenheit

Write a C program to input temperature in Celsius (centigrade) from user and convert to Fahrenheit. How to convert temperature from degree centigrade to degree Fahrenheit in C programming. C program for temperature conversion.


Example: 
Input temperature in Celsius = 100
Output temperature = 212 F

Required knowledge

Fundamentals of CData typesTalking user input in CTemperature conversion table 

Conversion formula

You can use the below conversion formula to convert temperature from degree Celsius to degree Fahrenheit 
°F = (°C * 9) / 5 + 32 

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 Celsius to Fahrenheit
 */
#include <stdio.h>
void main()
{
    float celsius, fahrenheit;
    // Reads temperature in celsius from user
    printf("Enter temperature in Celsius: ");
    scanf("%f", &celsius);
    // Converts temperature from celsius to fahrenheit
    fahrenheit = ((celsius * 9)/5) + 32;
    printf("\n%.2f Celsius = %.2f Fahrenheit", celsius, fahrenheit);
   
}


Output
X
_
Enter temperature in Celsius: 100

100 Celsius = 212.00 Fahrenheit

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

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