使用 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;
//get the limit of fibonacci series
printf("Enter Fahrenheit:
");
scanf("%f",&fahrenheit);
celsius = (fahrenheit - 32)*5/9;
printf("Celsius: %f
", celsius);
return 0;
}输出
执行上述程序后,将产生以下结果 −
Enter Fahrenheit: 100 Celsius: 37.777779
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP