使用 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