From f7bd45a856665dbe0d9837f7c12bb75d913665a2 Mon Sep 17 00:00:00 2001 From: Taylor Rogers Date: Tue, 18 Oct 2022 20:07:38 -0700 Subject: Finished exercise 1 --- CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp index 86f6e45..33af312 100644 --- a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp +++ b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp @@ -28,7 +28,7 @@ * 13) Step over one more time. * 14) Why didn't the value entered get transferred back to main? * -* because within main, age and days are set to zero at the beginning. +* because the new instance of "age" is a local variable contained with the int GetAge() curly brackets. * * 15) Stop debugging and fix the error. * 16) Run to Breakpoint 1. @@ -79,12 +79,13 @@ int GetAge(); int CalcDays(int age); void PrintResults(int age, int days); - +int age; +int days; int main() { - int age = 0; - int days = 0; + // int age = 0; + // int days = 0; // Breakpoint 1 // Put breakpoint on the following line @@ -99,7 +100,6 @@ int main() } int GetAge() { - int age; cout << "Please enter your age: "; cin >> age; @@ -108,7 +108,7 @@ int GetAge() } int CalcDays(int years) { - int days; + days = years * DAYS_PER_YEAR; -- cgit v1.2.3