Home >Backend Development >C#.Net Tutorial >C# program to convert Fahrenheit to Celsius

C# program to convert Fahrenheit to Celsius

WBOY
WBOYforward
2023-09-15 11:53:091265browse

将华氏温度转换为摄氏度的 C# 程序

First, set the temperature in Fahrenheit -

double fahrenheit = 97;
Console.WriteLine("Fahrenheit: " + fahrenheit);

Now convert it to Celsius -

celsius = (fahrenheit - 32) * 5 / 9;

Example

You You can try running the following code to convert Fahrenheit to Celsius.

Live Demo

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Demo {
   class MyApplication {
      static void Main(string[] args) {
         double celsius;
         double fahrenheit = 97;
         Console.WriteLine("Fahrenheit: " + fahrenheit);
         celsius = (fahrenheit - 32) * 5 / 9;
         Console.WriteLine("Celsius: " + celsius);
         Console.ReadLine();
      }
   }
}

Output

Fahrenheit: 97
Celsius: 36.1111111111111

The above is the detailed content of C# program to convert Fahrenheit to Celsius. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete
Previous article:Thread pool in C#Next article:Thread pool in C#