diff options
| author | Anibal LopezBonilla <[email protected]> | 2022-10-19 20:59:30 -0700 |
|---|---|---|
| committer | Anibal LopezBonilla <[email protected]> | 2022-10-19 20:59:30 -0700 |
| commit | 472927b1a83c993b71e8964ac09e85cd2abacf38 (patch) | |
| tree | 05f36c965d347b663faa2e2a2ceadb7fa689ac4c | |
| parent | Push 1 (diff) | |
| download | cst116-ch9-debugging-lopez-bonilla-472927b1a83c993b71e8964ac09e85cd2abacf38.tar.xz cst116-ch9-debugging-lopez-bonilla-472927b1a83c993b71e8964ac09e85cd2abacf38.zip | |
Most of work is done Added output file.
| -rw-r--r-- | CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp | 17 | ||||
| -rw-r--r-- | Ch8-Debugging Output.txt | 7 |
2 files changed, 22 insertions, 2 deletions
diff --git a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp index eff8980..47e481e 100644 --- a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp +++ b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp @@ -12,10 +12,16 @@ * 4) Add another watch using &age for the name. This will display
* the address of age.
* 5) Write down the address of age.
+*
+* ANS: 0x000000dfd68ff554{0}
+*
* 6) Step Into the code for the function GetAge.
* 7) The execution continues to the function header for GetAge.
* 8) Step into one more time.
* 9) Why did the address of age and value change?
+*
+* ANS: Because age has been defined to a different value.
+*
* 10) Step over the cout and cin statements.
* 11) Verify the value entered is stored properly in age.
* 12) Step into until the flow returns to main.
@@ -36,6 +42,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?
+*
+* ANS: Age was not in the calcdays function.
+*
* 6) Stop debugging.
*
* Debugging Exercise 3
@@ -47,6 +56,9 @@ * 4) Step into the PrintResults function.
* 5) Age is 7300? Not even Ralph is that old.
* 6) Why did the values for both variables change?
+*
+* ANS: The int order for age and days was switched
+*
* 7) Stop debugging and fix the error.
*
* Debugging Exercise 4
@@ -77,7 +89,7 @@ int main() // Breakpoint 1
// Put breakpoint on the following line
- GetAge();
+ age = GetAge();
days = CalcDays(age);
// Breakpoint 2
@@ -99,11 +111,12 @@ int CalcDays(int years) {
int days;
+
days = years * DAYS_PER_YEAR;
return days;
}
-void PrintResults(int days, int age)
+void PrintResults(int age, int days)
{
cout << age << "! Boy are you old!\n";
cout << "Did you know that you are at least " << days << " days old?\n\n";
diff --git a/Ch8-Debugging Output.txt b/Ch8-Debugging Output.txt new file mode 100644 index 0000000..44125c5 --- /dev/null +++ b/Ch8-Debugging Output.txt @@ -0,0 +1,7 @@ +Please enter your age: 20 +20! Boy are you old! +Did you know that you are at least 7300 days old? + + +C:\Users\speed\source\repos\cst116-ch9-debugging-Lopez-Bonilla\CST116-Ch9-Debugging\Debug\CST116-Ch9-Debugging.exe (process 48444) exited with code 0. +Press any key to close this window . . . |