From dc782f6988311bd3473ba7713e181ac267ee2818 Mon Sep 17 00:00:00 2001 From: alexandra-apetroaei Date: Tue, 18 Oct 2022 17:32:18 -0800 Subject: change --- CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 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..4234460 100644 --- a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp +++ b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp @@ -12,10 +12,12 @@ * 4) Add another watch using &age for the name. This will display * the address of age. * 5) Write down the address of age. +* // address of age: 0x000000112838fa44 {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? +* // Beacuase the code ignored the variable days * 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. @@ -60,6 +62,8 @@ * the stack. ********************************************************************/ #include + +using namespace std; using std::cout; using std::cin; using std::endl; @@ -67,22 +71,24 @@ using std::endl; const int DAYS_PER_YEAR = 365; int GetAge(); -int CalcDays(int age); -void PrintResults(int age, int days); +void CalcDays(int age); +void PrintResults(int age, int days); int main() { int age = 0; int days = 0; + int years = 0; + // Breakpoint 1 // Put breakpoint on the following line GetAge(); - days = CalcDays(age); + int days = CalcDays(age); // Breakpoint 2 // Put breakpoint on the following line - PrintResults(age, days); + PrintResults(age, days); return 0; } @@ -95,16 +101,16 @@ int GetAge() return age; } -int CalcDays(int years) +void CalcDays(years) { int days; days = years * DAYS_PER_YEAR; - return days; + return days; } void PrintResults(int days, int age) { - cout << age << "! Boy are you old!\n"; - cout << "Did you know that you are at least " << days << " days old?\n\n"; + cout << age << "! Boy are you old!" << endl; + cout << "Did you know that you are at least " << days << " days old?" << endl; } -- cgit v1.2.3