The source code to convert a Fahrenheit temperature into Celsius is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
//C# program to convert a Fahrenheit temperature into Celsius.
using System;
class Program
{
static double convertToCelsius(double ferTemp)
{
double cTemp = 0;
cTemp = (ferTemp - 32) * 5 / 9;
return cTemp;
}
static void Main(string[] args)
{
double celTemp=0;
double ferTemp=0;
Console.Write("Enter the value of temperature in Fahrenheite(°F): ");
ferTemp = double.Parse(Console.ReadLine());
celTemp = convertToCelsius(ferTemp);
Console.WriteLine("Celsius temperature is(°C) : " + celTemp);
}
}
Output:
Enter the value of temperature in Fahrenheite(°F): 90.5
Celsius temperature is(°C) : 32.5
Press any key to continue . . .
Explanation:
In the above program, we created a class Program that contains two static methods convertToCelsius() and Main(). The convertToCelsius() method is used to convert the Fahrenheit temperature into Celsius.
In the Main() method, we read the value of temperature in Fahrenheit and then convert the temperature into Celsius using convertToCelsius() method and print the result on the console screen.
Program:
The source code to convert a Fahrenheit temperature into Celsius is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created a class Program that contains two static methods convertToCelsius() and Main(). The convertToCelsius() method is used to convert the Fahrenheit temperature into Celsius.
In the Main() method, we read the value of temperature in Fahrenheit and then convert the temperature into Celsius using convertToCelsius() method and print the result on the console screen.