Menu
Coddy logo textTech

Basic Output

Lesson 8 of 10 in Coddy's Temperature Converter using C++ course.

Now, we have all the converters! Let's create the user interface (main function) so the user of this program will be able to use the temperature converter easily.

challenge icon

Challenge

Easy

Add the main function to your code (below all your converters functions). Inside the function, print the following:

Temperature Converter
1. Celsius to Fahrenheit
2. Celsius to Kelvin
3. Fahrenheit to Celsius
4. Fahrenheit to Kelvin
5. Kelvin to Celsius
6. Kelvin to Fahrenheit

Try it yourself

float celsiusToFahrenheit(float celsius) {
    return (celsius * 9.0 / 5.0) + 32.0;
}

double celsiusToKelvin(double celsius) {
    return celsius + 273.15;
}

double fahrenheitToCelsius(double fahrenheit) {
    return (fahrenheit - 32.0) * 5.0 / 9.0;
}

double fahrenheitToKelvin(double fahrenheit) {
    return (fahrenheit + 459.67) * 5.0 / 9.0;
}

double kelvinToCelsius(double kelvin) {
    return kelvin - 273.15;
}

double kelvinToFahrenheit(double kelvin) {
    return kelvin * 9.0 / 5.0 - 459.67;
}

All lessons in Temperature Converter using C++