aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch9-Debugging
diff options
context:
space:
mode:
authorTaylor Rogers <[email protected]>2022-10-18 20:07:38 -0700
committerTaylor Rogers <[email protected]>2022-10-18 20:07:38 -0700
commitf7bd45a856665dbe0d9837f7c12bb75d913665a2 (patch)
tree0d2f004d244077cfefd958f0428c360ee3aff286 /CST116-Ch9-Debugging
parentQ14 (diff)
downloadcst116-ch9-debugging-taylorrog-f7bd45a856665dbe0d9837f7c12bb75d913665a2.tar.xz
cst116-ch9-debugging-taylorrog-f7bd45a856665dbe0d9837f7c12bb75d913665a2.zip
Finished exercise 1
Diffstat (limited to 'CST116-Ch9-Debugging')
-rw-r--r--CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp12
1 files 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;