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 121 views
1 answer 119 views
1 answer 108 views
1 answer 121 views
1 answer 130 views
1 answer 122 views
1 answer 112 views
...