From 88ef655a6ef739795664b9be1d80e631da185335 Mon Sep 17 00:00:00 2001 From: CEOofOogaBooga Date: Tue, 18 Oct 2022 21:39:53 -0700 Subject: Chp9 Finished --- CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 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 f78a1b6..3be9c13 100644 --- a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp +++ b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp @@ -19,12 +19,13 @@ * 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? -* E +* It changed because "age" became undefined as there are 2 different "age" * 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. * 13) Step over one more time. * 14) Why didn't the value entered get transferred back to main? +* because the "age" are different between the one under main and the one in GetAge * 15) Stop debugging and fix the error. * 16) Run to Breakpoint 1. * 17) Step over the function call to GetAge. @@ -40,6 +41,7 @@ * 4) Step into one more time so that the current line is the * calculation. * 5) Why is age greyed out in your watch window? +* The reason age is greyed is because years is a parameter * 6) Stop debugging. * * Debugging Exercise 3 @@ -51,6 +53,7 @@ * 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? +* Because the "age" and "day" were inputed in the wrong order * 7) Stop debugging and fix the error. * * Debugging Exercise 4 @@ -72,7 +75,7 @@ const int DAYS_PER_YEAR = 365; int GetAge(); int CalcDays(int age); -void PrintResults(int age, int days); +void PrintResults(int days, int age); int main() { @@ -81,12 +84,12 @@ int main() // Breakpoint 1 // Put breakpoint on the following line - GetAge(); + age = GetAge(); days = CalcDays(age); // Breakpoint 2 // Put breakpoint on the following line - PrintResults(age, days); + PrintResults(days, age); return 0; } @@ -107,6 +110,11 @@ int CalcDays(int years) return days; } +/// +/// It prints results +/// +/// The days to be displayed +/// the age to be displayed void PrintResults(int days, int age) { cout << age << "! Boy are you old!\n"; -- cgit v1.2.3