In this C program, we will learn how to write a program to perform the conversion from Celsius to Fahrenheit.
0 °C = 32 °F
The Formula is used for Converting temperature from celsius to Fahrenheit is as follows:
T(°F) = T(°C) × 9/5 + 32
or
T(°F) = T(°C) × 1.8 + 32
Where, T = Temperature,
°F = Fahrenheit,
°C = Celsius
Here is the code of the program to program to perform the conversion from Celsius to Fahrenheit.
using System;
namespace Tutorialsrack
{
class Program
{
/* C# Program to Perform Celsius to Fahrenheit Conversion */
static void Main(string[] args)
{
decimal Temperature_in_Celsius, Fahrenheit;
Console.Write("Enter the Temperature in Celsius(°C) : ");
Temperature_in_Celsius = decimal.Parse(Console.ReadLine());
Fahrenheit = (Temperature_in_Celsius * 9) / 5 + 32;
Console.WriteLine("{0} °C Temperature in Fahrenheit is(°F) : {1}", Temperature_in_Celsius, Fahrenheit);
//Hit ENTER to exit the program
Console.ReadKey();
}
}
}
Enter the Temperature in Celsius(°C) : 37.5
37.5 °C Temperature in Fahrenheit is(°F) : 99.5
Comments