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

C# program to convert Fahrenheit to Celsius

WBOY
Release: 2023-09-15 11:53:09
forward
1267 people have browsed it

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

First, set the temperature in Fahrenheit -

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

Now convert it to Celsius -

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

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();
      }
   }
}
Copy after login

Output

Fahrenheit: 97
Celsius: 36.1111111111111
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template