使用 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 语言程序 −

Open Compiler
#include<stdio.h> int main(){ float fahrenheit, celsius; //get the limit of fibonacci series printf("Enter Fahrenheit: "); scanf("%f",&fahrenheit); celsius = (fahrenheit - 32)*5/9; printf("Celsius: %f ", celsius); return 0; }

Explore our latest online courses and learn new skills at your own pace. Enroll and become a certified expert to boost your career.

输出

执行上述程序后,将产生以下结果 −

Enter Fahrenheit:

100
Celsius: 37.777779

更新时间: 2023-11-04

48K+ 浏览量

启动您的 职业

通过完成课程获得认证

开始
广告