使用C程序将华氏温度转换为摄氏温度
我们实现的将华氏温度转换为摄氏温度的逻辑如下-
celsius = (fahrenheit - 32)*5/9;
算法
请参阅下面给出的将华氏温度转换为摄氏温度的算法。
Step 1: Declare two variables farh, cels Step 2: Enter Fahrenheit value at run time Step 3: Apply formula to convert Cels=(farh-32)*5/9; Step 4: Print cels
示例
以下是将华氏温度转换为摄氏温度的C程序-
#include<stdio.h> int main(){ float fahrenheit, celsius; //得到斐波那契数列的极限 printf("Enter Fahrenheit: \n"); scanf("%f",&fahrenheit); celsius = (fahrenheit - 32)*5/9; printf("Celsius: %f \n", celsius); return 0; }输出结果
执行以上程序后,将产生以下结果-
Enter Fahrenheit: 100 Celsius: 37.777779