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,885 questions

51,811 answers

573 users

How to convert fahrenheit to celsius in C++

3 Answers

0 votes
#include <iostream>
#include <iomanip>

int main()
{
    float f = 1.0, c;
     
    c = (f - 32) / 1.8;
 
    std::cout <<  std::fixed << std::setprecision(2) << f << " Fahrenheit = " << 
                  std::fixed << std::setprecision(2) << c  << " celsius" << "\n";
}



 
/*
run:
 
1.00 Fahrenheit = -17.22 celsius
 
*/

 



answered Feb 19, 2016 by avibootz
edited Jul 22, 2022 by avibootz
0 votes
#include <iostream>
#include <iomanip>

int main()
{
    float f = 1.0, c;
     
    c = (f - 32) * (5.0 / 9.0);
 
    std::cout <<  std::fixed << std::setprecision(2) << f << " fahrenheit = " << 
                  std::fixed << std::setprecision(2) << c  << " celsius" << "\n";
}



 
/*
run:
 
1.00 fahrenheit = -17.22 celsius
 
*/

 



answered Feb 19, 2016 by avibootz
edited Jul 22, 2022 by avibootz
0 votes
#include <iostream>
 
int main() {
     
 int fahrenheit = 96;
       
    double celsius = (fahrenheit - 32) * 5 / 9.0;
       
    std::cout << "Celsius = " << celsius;
}
   
   
   
   
/*
run:
     
Celsius = 35.5556
    
*/

 



answered Jul 22, 2022 by avibootz

Related questions

1 answer 87 views
1 answer 84 views
1 answer 158 views
158 views asked Jul 15, 2021 by avibootz
1 answer 201 views
1 answer 91 views
1 answer 83 views
1 answer 190 views
190 views asked Jul 15, 2021 by avibootz
...