📌  相关文章
📜  摄氏到华氏度转换的程序

📅  最后修改于: 2021-04-25 01:15:16             🧑  作者: Mango

在摄氏温度为n的情况下,您的任务是将其转换为华氏度。
例子:

Input : 0
Output : 32

Input : -40
Output : -40

将摄氏度转换为华氏度的公式

T(°F) = T(°C) × 9/5 + 32
C++
// CPP program to convert Celsius
// scale  to Fahrenheit scale
#include 
using namespace std;
 
// function to convert Celsius
// scale to Fahrenheit scale
float Cel_To_Fah(float n)
{
    return ((n * 9.0 / 5.0) + 32.0);
}
 
// driver code
int main()
{
    float n = 20.0;
    cout << Cel_To_Fah(n);
    return 0;
}


Java
// Java program to convert Celsius
// scale to Fahrenheit scale
class GFG
{
// function to convert Celsius
// scale to Fahrenheit scale
static float Cel_To_Fah(float n)
{
    return ((n * 9.0f / 5.0f) + 32.0f);
}
 
// Driver code
public static void main(String[] args) {
    float n = 20.0f;
    System.out.println(Cel_To_Fah(n));
}
}
 
// This code is contributed by Anant Agarwal.


Python3
# Python code to convert Celsius scale
# to Fahrenheit scale
def Cel_To_Fah(n):
     
    # Used the formula
    return (n*1.8)+32
 
# Driver Code
n = 20
print(int(Cel_To_Fah(n)))
 
# This code is contributed by Chinmoy Lenka


C#
// C# program to convert Celsius
// scale to Fahrenheit scale
using System;
 
class GFG  {
     
// function to convert Celsius
// scale to Fahrenheit scale
static float Cel_To_Fah(float n)
{
    return ((n * 9.0f / 5.0f) + 32.0f);
}
 
// Driver code
public static void Main()
{
    float n = 20.0f;
    Console.Write(Cel_To_Fah(n));
}
}
 
// This code is contributed by Nitin Mittal.


PHP


Javascript


输出:

68