Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,950 questions

51,892 answers

573 users

How to convert fahrenheit to celsius in C#

3 Answers

0 votes
using System;

class Program
{
    static double FahrenheitToCelsius(double f) {
        double t;
 
        t = (f - 32) * (5.0 / 9.0);
 
        return t;
    }
    static void Main() {
        try {
            Console.Write("Enter Temperature in Fahrenheit: ");
            double temp_f = Convert.ToDouble(Console.ReadLine());
            double temp_c = FahrenheitToCelsius(temp_f);
            Console.WriteLine("{0:F2} Fahrenheit = {1:F2} Celsius\n", temp_f, temp_c);
        }
        catch (Exception ex) {
            Console.WriteLine(ex.Message);
        }
    }
}





/*
run:
    
Enter Temperature in Fahrenheit: 1
1.00 Fahrenheit = -17.22 Celsius
 
Enter Temperature in Fahrenheit: 50
50.00 Fahrenheit = 10.00 Celsius
   
*/


answered May 2, 2015 by avibootz
edited Jul 22, 2022 by avibootz
0 votes
using System;
   
class Program
{
    public static double FahrenheitToCelsius(double f) {
            return (5.0 / 9.0) * (f - 32);
    }
   
    static void Main()
    {
        int f = 100;
 
        Console.WriteLine("{0} = {1:N4}", f, FahrenheitToCelsius(f));
    }
}
   
   
    
    
/*
run:
   
100 = 37.7778
   
*/

 



answered Jul 22, 2022 by avibootz
0 votes
using System;
  
class Program
{
    static void Main() {
        int fahrenheit = 96;
         
        double celsius = (fahrenheit - 32) * 5 / 9.0;
         
        Console.WriteLine("Celsius = " + celsius);
    }
}
  
  
  
      
/*
run:
      
Celsius = 35.5555555555556
      
*/

 



answered Jul 22, 2022 by avibootz

Related questions

1 answer 107 views
1 answer 179 views
179 views asked Sep 14, 2020 by avibootz
1 answer 86 views
1 answer 97 views
1 answer 86 views
...