How to make C program to convert Fahrenheit into Celsius

How to make C program to convert Fahrenheit into Celsius

Temperature conversion formula

Temperature conversion formula from degree Celsius to Fahrenheit is given by -

Celsius = 5/9(Farenhite - 32)

The logic to convert temperature from Celsius to Fahrenheit

The logic of temperature conversion exists in converting the mathematical formula to C expression. You just need to convert mathematical formula of temperature in C language. Rest is simple input/output.
Below is the step by step descriptive logic to convert temperature from degree Celsius to Fahrenheit.
  1. Input temperature in Celsius from the user. Store it in some variable say celsius.
  2. Apply formula to convert the temperature to Fahrenheit i.e.fahrenheit = (celsius * 9 / 5) + 32
  3. Print the value of Fahrenheit.
                

Program to convert temperature from Celsius to Fahrenheit

/** * C program to convert temperature from degree celsius to fahrenheit */ #include <stdio.h> int main() { float celsius, fahrenheit; /* Input temperature in celsius */ printf("Enter temperature in Celsius: "); scanf("%f", &celsius); /* celsius to fahrenheit conversion formula */ fahrenheit = (celsius * 9 / 5) + 32; printf("%.2f Celsius = %.2f Fahrenheit", celsius, fahrenheit); return 0; }

Comments

Popular posts from this blog

Brick Breaker Game in JAVA