Temperature Converter
Converts degrees Celsius to Fahrenheit and Kelvin.
- Level
- Beginner
- Topic:
- First steps
- Concepts:
- Input & output
- Variables
- Math
Open in Codoritmo
Run, change and debug this example in your browser.
What you'll learn
You work with Real variables and the <- assignment operator. The formulas use *, / and + just like in math class.
Code
Algoritmo ConversorTemperatura Definir celsius, fahrenheit, kelvin Como Real Escribir "Temperatura en grados Celsius:" Leer celsius fahrenheit <- celsius * 9 / 5 + 32 kelvin <- celsius + 273.15 Escribir celsius, " °C equivalen a ", fahrenheit, " °F" Escribir celsius, " °C equivalen a ", kelvin, " K"FinAlgoritmoFlowchart
Each block in the flowchart matches one instruction in the code.
Sample run
This is what the program shows when it runs. The answers typed by the user are highlighted.
Temperatura en grados Celsius:User answer: 2525 °C equivalen a 77 °F25 °C equivalen a 298.15 K
Challenge
Go the other way: ask for Fahrenheit and convert it to Celsius.
Show hint
Reverse the formula: subtract 32, then multiply by 5 / 9.
Related examples
Fibonacci Sequence
Prints the first terms of the Fibonacci sequence.
BeginnerHello World
Your first algorithm: print a couple of messages on screen.
BeginnerBody Mass Index
Computes your BMI and classifies it as underweight, normal and so on.
Intermediate