How to convert Celsius to Fahrenheit and kelvin in C++

1 Answer

0 votes
#include <iostream>

int main() {
    int celsius = 24;
     
    float fahrenheit = ((9.0 / 5.0) * celsius) + 32;
    
    float kelvin = celsius + 273.15;

    std::cout << "Fahrenheit = " << fahrenheit << "\n";
    std::cout << "Kelvin = " << kelvin << "\n";
}


        
/*
run:

Fahrenheit = 75.2
Kelvin = 297.15
     
*/

 



answered Dec 14, 2024 by avibootz

Related questions

1 answer 125 views
1 answer 123 views
1 answer 113 views
1 answer 127 views
1 answer 134 views
1 answer 131 views
1 answer 117 views
...