 Let's take another look at the Agent Days program. The only problem with it is that if you want to try a different age, you need to change the code and rebuild it. What you'd really like to do is ask the user what their age is, read their answer from the keyboard, and use that in the formula. And you can do that with the scanf() function. Let's change the program, first by updating the pseudocode in our comments. First we'll set the age and years to zero to declare the variable. Then we're going to prompt the user for their age and years. Then we'll read their input into the years variable. Everything else will remain exactly as it was before. Now we'll update the code to match it. We set our years to zero and prompt the user. Two things to notice about this. First, we don't have a backslash n at the end of the string. We want the input cursor to appear on the same line as the prompt, not on a new line. Second, I left a space before the closing quote mark. That will leave some breathing room between the prompt and the cursor. Now we read the input using scanf. Like printf, scanf has a formatting string as its first argument. For integers, we use %d instead of %i. In printf they're the same, but in scanf they do different things and %d is better. The remaining argument gives the variable you want to read into. You must proceed the variable name with an ampersand, which you can think of as the memory address of operator. We'll talk more about this operator much later on in the course. Let's build the program and let's run it. Now I can enter any age I want. If the person is 34 years old, they enter 34 and it gives them the answer. The next time I run the program, I can enter a different age in years and get the appropriate answer. You can read more than one item at a time with scanf by having multiple placeholders. Take a look at this program, where we'll prompt the user for three numbers, read them in and then get the average by adding them up and dividing by three. Here's our prompt, again without a backslash n and with a space for our breathing room. In scanf we have three placeholders. To read into a double, you use the %lf specifier. And because we have three formatting specifiers, we need to specify three variables. And again we use the ampersand memory address of operator before each one. Then the calculation and then printing the result. Let's build this and run it and enter our three numbers like 3.7, 8.4 and 12.2 and there's the average of those three numbers. Here are the formatting characters to use with scanf. The entry for float is in the table for completeness. Again use double in preference to float. There's no formatting character for boolean. Instead you have to read into an int variable and then assign that int to the boolean. Again, when reading input make sure you prompt the user. The first argument to scanf is your formatting string with placeholders for the variable or variables you want to read followed by the variable names, each name preceded by the ampersand operator.