aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp')
-rw-r--r--CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp17
1 files changed, 15 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";