Given a Temperature n in Fahrenheit scale convert it into Celsius scale .
Examples:
Input : 32 Output : 0 Input :- 40 Output : -40
Formula for converting Fahrenheit scale to Celsius scale
T(°C) = (T(°F) - 32) × 5/9
C++
// CPP program to convert Fahrenheit // scale to Celsius scale #include <bits/stdc++.h> using namespace std; // function to convert // Fahrenheit to Celsius float Conversion(float n) { return (n - 32.0) * 5.0 / 9.0; } // driver code int main() { float n = 40; cout << Conversion(n); return 0; } |
chevron_right
filter_none
Java
// Java program to convert Fahrenheit // scale to Celsius scale class GFG { // function to convert // Fahrenheit to Celsius static float Conversion(float n) { return (n - 32.0f) * 5.0f / 9.0f; } // Driver code public static void main(String[] args) { float n = 40; System.out.println(Conversion(n)); } } // This code is contributed by Anant Agarwal. |
chevron_right
filter_none
Python3
# Python3 program to convert Fahrenheit # scale to Celsius scale # function to convert # Fahrenheit to Celsius def Conversion(n): return(n - 32.0) * 5.0 / 9.0 # driver code n = 40x = Conversion(n) print (x) # This article is contributed by Himanshu Ranjan |
chevron_right
filter_none
C#
// c# program to convert Fahrenheit // scale to Celsius scale using System; class GFG { // function to convert // Fahrenheit to Celsius static float Conversion(float n) { return (n - 32.0f) * 5.0f / 9.0f; } // Driver code public static void Main() { float n = 40; Console.Write(Conversion(n)); } } // This code is contributed by Nitin Mittal. |
chevron_right
filter_none
PHP
<?php // PHP program to convert Fahrenheit // scale to Celsius scale // function to convert // Fahrenheit to Celsius function Conversion($n) { return ($n - 32.0) * 5.0 / 9.0; } // Driver Code $n = 40; echo Conversion($n); // This code is contributed by nitin mittal ?> |
chevron_right
filter_none
Output:
4.44444
This article is contributed by Dibyendu Roy Chaudhuri. 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 write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Recommended Posts:
- Program for Celsius To Fahrenheit conversion
- Program for Fahrenheit to Kelvin conversion
- Program to convert temperature from degree Celsius to Kelvin
- Program for decimal to hexadecimal conversion
- Case conversion (Lower to Upper and Vice Versa) of a string using BitWise operators in C/C++
- Base conversion in Java
- Catch block and type conversion in C++
- Program to check if a date is valid or not
- Program to print the diamond shape
- Program to print Happy Birthday
- Java program to check palindrome (using library methods)
- Program to print a pattern of numbers
- Python Program to print digit pattern
- Program to find sum of elements in a given array
- C Program to Swap two Numbers
- Program to find largest element in an array
- Program for Tower of Hanoi
- Program to cyclically rotate an array by one
- Program to find GCD or HCF of two numbers
- Program to find LCM of two numbers
Improved By : nitin mittal

