Celsius to Fahrenheit :
Formula:
$ F = (C \times {\frac{9}{5}}) + 32 $
- $F$ : Temperature in Fahrenheit scale
- $C$ : Temperature in Celsius scale
#include "iostream" using namespace std; #define pi 3.14159 int main() { float farenheit, celsius; cout << "Enter the temperature in celsius :" ; cin >> celsius ; // celsius to fareheit farenheit = (celsius * 9.0) / 5.0 + 32; cout << "Temperature in celsius : " << celsius << endl; cout << "Temperature in fahrenheit : " << farenheit ; return (0); }INPUT: Enter the temperature in celsius : 35
OUTPUT : Temperature in Celsius : 35
Temperature in Fahrenheit: 95
Celsius to Kelvin
Formula:
$K = C + 273.15$
- $K$ : Temperature in Kelvin scale
- $C$ : Temperature in Celsius scale
#include "iostream" using namespace std; #define pi 3.14159 int main() { float Kelvin, celsius; cout << "Enter the temperature in celsius :" ; cin >> celsius ; // celsius to kelvin Kelvin = celsius + 273.15; cout << "Temperature in celsius : " << celsius << endl; cout << "Temperature in kelvin : " << Kelvin ; return (0); }
INPUT: Enter the temperature in celsius : 35
OUTPUT : Temperature in Celsius : 35
Temperature in kelvin: 308.15
No comments:
Post a Comment