November 2013
Beginner
325 pages
9h 47m
English
In a function definition, any pair of curly braces { ... }) define the scope of the code that is in between them. A variable cannot be accessed outside of the scope that it is declared in. In fact, it does not exist outside of the scope that it is declared in.
Any pair of braces, whether they are a part of a function definition, an if statement, or a loop, defines its own scope that restricts the availability of any variables declared within them.
Add the following code to your showCookTimeForTurkey function:
void showCookTimeForTurkey(int pounds)
{
int necessaryMinutes = 15 + 15 * pounds;
printf("Cook for %d minutes.\n", necessaryMinutes);
if (necessaryMinutes > 120) {
int halfway = necessaryMinutes / 2;
printf("Rotate ...Read now
Unlock full access