Fahrenheit to centigrade conversion using c program!


Fahrenheit to centigrade conversion using c
Fahrenheit to centigrade conversion using c program!
We know the equation,
(C/5) ={(F-32)/9}
Here,
C define Centigrade
F define Fahrenheit
So, if we need centigrade value from Fahrenheit then,

(C/5) =(F-32)/9
or, C=5(F-32)/9
or, C=(5F-160)/9

So, the algorithm is,

step1: Start the program
step2: Input a Fahrenheit value ‘f’
step3: C=(5F-160)/9
step4: Print ‘C’ which is Centigrade value
step5: End the program

Code:

#include <stdio.h>
int main()
{

    float f;
    float c;
    printf("Enter Your temperature in Fahrenheit  ");

    scanf("%f",&f);

    c=(5*f-160)/9;

    printf("Your temperature in centigrade is %f",c);

    return 0;

}

Fahrenheit to centigrade conversion using c

Explanation:
Here “float f;” means you can use Fahrenheit valued which is a floating number. “float c;” means you can use centigrade value which is a floating number. “printf("Enter Your temperature in Fahrenheit  ");” means it will show users a command that what they have to do. “scanf("%f",&f);” means it will pick a floating number which is the value of temperature in Fahrenheit scale. “%f” means the compiler will get floating number.    “c=(5*f-160)/9;”  is the main equation!  “printf("Your temperature in centigrade is %f",c);” means we will get the value of “C”.

Test (Do it yourself):
Write a c program which can do centigrade to Fahrenheit conversion.
Clue:
complete the equation first. F= (9C+160)/5

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.