Cプログラミング
 Computer >> コンピューター >  >> プログラミング >> Cプログラミング

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: \n");
   scanf("%f",&fahrenheit);
   celsius = (fahrenheit - 32)*5/9;
   printf("Celsius: %f \n", celsius);
   return 0;
}

出力

上記のプログラムを実行すると、次の結果が得られます-

Enter Fahrenheit:

100
Celsius: 37.777779

  1. 華氏を摂氏に変換する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 >>

  2. Pythonを使用して摂氏を華氏に変換する方法は?

    摂氏に相当する華氏を取得するには、1.8を掛けて32を足します f=c*1.8+32 次の通訳アクティビティはコンバージョンを示します >>> c=50 >>> f=c*1.8+32 >>> f 122.0