C++ 程式將華氏轉換成攝氏度


在這個程式中,我們將瞭解如何使用 C++ 將攝氏度轉換成華氏度。我們知道公式很簡單。

演算法

Begin
Take the Celsius temperature in C
calculate F = (9C/5)+32
return F
End

程式碼示例

#include<iostream>
using namespace std;
main() {
   float f, c;
   cout << "Enter temperature in Celsius: ";
   cin >> c;
   f = (9.0*c/5.0)+32;
   cout << "Equivalent Fahrenheit temperature is: " << f;
}

輸出

Enter temperature in Celsius: 37
Equivalent Fahrenheit temperature is: 98.6

更新於:30-7-2019

4K+ 瀏覽量

開始您的 職業生涯

完成課程,獲得認證

開始
廣告
© . All rights reserved.