aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp
diff options
context:
space:
mode:
authoralexandra-apetroaei <andra@MSI>2022-10-18 17:32:18 -0800
committeralexandra-apetroaei <andra@MSI>2022-10-18 17:32:18 -0800
commitdc782f6988311bd3473ba7713e181ac267ee2818 (patch)
tree3c7e954095f6e173ee6e136d422d7ffec4dbe371 /CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp
parentfirst change (diff)
downloadcst116-ch9-debugging-alexandra-apetroaei-dc782f6988311bd3473ba7713e181ac267ee2818.tar.xz
cst116-ch9-debugging-alexandra-apetroaei-dc782f6988311bd3473ba7713e181ac267ee2818.zip
change
Diffstat (limited to 'CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp')
-rw-r--r--CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp22
1 files changed, 14 insertions, 8 deletions
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 <iostream>
+
+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;
}