diff options
| author | Taylor Rogers <[email protected]> | 2022-10-18 20:30:50 -0700 |
|---|---|---|
| committer | Taylor Rogers <[email protected]> | 2022-10-18 20:30:50 -0700 |
| commit | 3b0b545890038a7a59eab0253eb3bb0d92f99b13 (patch) | |
| tree | 5b05e4461054dd98e20556311c59095edae59314 | |
| parent | Finished exercise 1 (diff) | |
| download | cst116-ch9-debugging-taylorrog-3b0b545890038a7a59eab0253eb3bb0d92f99b13.tar.xz cst116-ch9-debugging-taylorrog-3b0b545890038a7a59eab0253eb3bb0d92f99b13.zip | |
Answered E2 Q5
| -rw-r--r-- | CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp index 33af312..f3d67a8 100644 --- a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp +++ b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp @@ -20,7 +20,7 @@ * 8) Step into one more time.
* 9) Why did the address of age and value change?
*
-* Looks like a new instance of a variable named "age" was created with "int age;". This new variable would have a new address and deault value.
+* Looks like a new declaration of a variable named "age" was created with "int age;". This new variable would have a new address and deault value.
*
* 10) Step over the cout and cin statements.
* 11) Verify the value entered is stored properly in age.
@@ -31,6 +31,9 @@ * because the new instance of "age" is a local variable contained with the int GetAge() curly brackets.
*
* 15) Stop debugging and fix the error.
+*
+* I put the delcaration of "age" and "days" at the top
+*
* 16) Run to Breakpoint 1.
* 17) Step over the function call to GetAge.
* 18) Verify that the value entered was returned and stored
@@ -45,6 +48,9 @@ * 4) Step into one more time so that the current line is the
* calculation.
* 5) Why is age greyed out in your watch window?
+*
+* It is not greyed out, maybe I already fixed it by moving both variables?
+*
* 6) Stop debugging.
*
* Debugging Exercise 3
@@ -74,13 +80,13 @@ using std::cin; using std::endl;
const int DAYS_PER_YEAR = 365;
+int age;
+int days;
int GetAge();
int CalcDays(int age);
void PrintResults(int age, int days);
-int age;
-int days;
int main()
{
|