Chapter 5. Input

Until now, if you wanted your program to “crunch some numbers,” you had to put those numbers right in the code. For example, if you wrote the temperature-conversion program in the “Try it out” section of chapter 3, you probably put the temperature to convert right in the code. If you wanted to convert a different temperature, you would have had to change the code.

What if you want to have the user enter any temperature they want when the program runs? We said before that a program has three components: input, processing, and output. Our first program had only output. The temperature-conversion program had some processing (converting the temperature) and some output, but no input. It’s time to add the third ingredient to our ...

Get Hello World! Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.