From 472927b1a83c993b71e8964ac09e85cd2abacf38 Mon Sep 17 00:00:00 2001 From: Anibal LopezBonilla Date: Wed, 19 Oct 2022 20:59:30 -0700 Subject: Most of work is done Added output file. --- CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp') 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"; -- cgit v1.2.3