# C# program to convert a temperature from Fahrenheit into Celsius

Here, we are going to learn how to convert a temperature from Fahrenheit into Celsius in C#? By Nidhi Last updated : April 15, 2023

## Fahrenheit into Celsius Conversion C#

Here we will read the temperature in Fahrenheit and then convert it into the corresponding temperature Celsius.

## C# code for Fahrenheit into Celsius conversion

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.

Comments and Discussions!

Student's Section
Subscribe

Copyright © 2024 www.includehelp.com. All rights reserved.