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

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,038 questions

40,787 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 53 views
1 answer 76 views
1 answer 64 views
64 views asked Jul 15, 2021 by avibootz
3 answers 160 views
160 views asked Apr 30, 2015 by avibootz
1 answer 46 views
...