# Program for Celsius To Fahrenheit conversion

Given a Temperature N on the Celsius scale, your task is to convert it into a Fahrenheit scale.

Examples:

Input: 0
Output: 32

Input: -40
Output: -40

The formula for converting the Celsius scale to the Fahrenheit scale is:

T(Â°F) = T(Â°C) Ã— 9/5 + 32

Below is the implementation of the above idea.

## C

 `/* C Program to convert temperature from Celsius to `` ``* Fahrenheit*/``#include `` ` `// function for conversion ``float` `celsius_to_fahrenheit(``float` `N) ``{ ``    ``return` `((N * 9.0 / 5.0) + 32.0); ``} `` ` `// Driver code ``int` `main() ``{ ``    ``float` `N = 20.0; `` ` `    ``// Function call ``    ``printf``(``"Temperature in Fahrenheit : %0.2f"``, ``           ``celsius_to_fahrenheit(N)); ``    ``return` `0; ``}`

## C++

 `// C++ 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; ``   ` `      ``// Function call ``    ``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; ``       ` `          ``// Function call ``        ``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 ``if` `__name__ ``=``=` `"__main__"``: ``  ``n ``=` `20`` ` `  ``# Function call ``  ``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; ``       ` `          ``// Function call ``        ``Console.Write(Cel_To_Fah(N)); ``    ``} ``} `` ` `// This code is contributed by Nitin Mittal.`

## PHP

 ``

## Javascript

 ``

Output
`Temperature in Fahrenheit : 68.00`

Time Complexity: O(1), as we are performing simple mathematical operations
Auxiliary Space: O(1), as we are not using any extra space

Previous
Next