Given a Temperature ‘n’ in Celsius scale, your task is to convert it into Fahrenheit scale.
Examples:
Input : 0 Output : 32 Input : -40 Output : -40
Formula for converting Celsius scale to Fahrenheit scale
T(°F) = T(°C) × 9/5 + 32
C++
// CPP program to convert Celsius // scale to Fahrenheit scale #include <bits/stdc++.h> 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; } |
chevron_right
filter_none
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. |
chevron_right
filter_none
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 = 20print(int(Cel_To_Fah(n))) # This code is contributed by Chinmoy Lenka |
chevron_right
filter_none
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. |
chevron_right
filter_none
PHP
<?php // PHP program to convert Celsius // scale to Fahrenheit scale // function to convert Celsius // scale to Fahrenheit scale function Cel_To_Fah($n) { return (($n * 9.0 / 5.0) + 32.0); } // Driver Code $n = 20.0; echo Cel_To_Fah($n); // This code is contributed by nitin mittal ?> |
chevron_right
filter_none
Output:
68
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- Program for Fahrenheit to Celsius conversion
- Program for Fahrenheit to Kelvin conversion
- Program to convert temperature from degree Celsius to Kelvin
- Program for Binary To Decimal Conversion
- Program for Decimal to Binary Conversion
- Program for decimal to hexadecimal conversion
- Gray to Binary and Binary to Gray conversion
- Case conversion (Lower to Upper and Vice Versa) of a string using BitWise operators in C/C++
- Print all substring of a number without any conversion
- Decimal to binary conversion without using arithmetic operators
- Base conversion in Java
- Postfix to Prefix Conversion
- Catch block and type conversion in C++
- Number from a range [L, R] having Kth minimum cost of conversion to 1 by given operations
- Write a program to reverse digits of a number
- Program to find parity
- Write an Efficient C Program to Reverse Bits of a Number
- Write a program to print all permutations of a given string
- Program to find amount of water in a given glass
- Program to convert a given number to words
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nitin mittal

