aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralexandra-apetroaei <andra@MSI>2022-10-19 13:25:49 -0800
committeralexandra-apetroaei <andra@MSI>2022-10-19 13:25:49 -0800
commit7f45716a258611d98b9711a815466989a62b5a1e (patch)
tree59e55cad72bf42db68a603755c764940b9cc19bf
parentfinial (diff)
downloadcst116-ch9-debugging-alexandra-apetroaei-7f45716a258611d98b9711a815466989a62b5a1e.tar.xz
cst116-ch9-debugging-alexandra-apetroaei-7f45716a258611d98b9711a815466989a62b5a1e.zip
Igrnore final I'm still working
-rw-r--r--CST116-Ch9-Debugging/CST116-Ch9-Debugging-Apetroaei.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/CST116-Ch9-Debugging/CST116-Ch9-Debugging-Apetroaei.cpp b/CST116-Ch9-Debugging/CST116-Ch9-Debugging-Apetroaei.cpp
index c9fc75d..7fce779 100644
--- a/CST116-Ch9-Debugging/CST116-Ch9-Debugging-Apetroaei.cpp
+++ b/CST116-Ch9-Debugging/CST116-Ch9-Debugging-Apetroaei.cpp
@@ -12,12 +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}
+* // address of age: 0x000000112838fa44
* 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
+* // Beacuase age is being defined again so it isn't set
* 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.
@@ -69,21 +69,19 @@ using std::endl;
const int DAYS_PER_YEAR = 365;
-int GetAge();
-int CalcDays(int age);
-void PrintResults(int age, int days);
+int GetAge ();
+int 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();
- int days = CalcDays( age);
+ age = GetAge( );
+ days = CalcDays( age);
// Breakpoint 2
// Put breakpoint on the following line
@@ -95,7 +93,7 @@ int GetAge()
{
int age;
- cout << "Please enter your age: " << endl;
+ cout << "Please enter your age: ";
cin >> age;
return age;
@@ -104,12 +102,12 @@ int CalcDays( int years)
{
int days;
- days = int years * const int DAYS_PER_YEAR;
+ days = years * DAYS_PER_YEAR;
return days;
}
void PrintResults(int age, int days)
{
- cout << age << " ! Boy are you old!" << endl ;
- cout << " Did you know that you are at least " << days << " days old?" << endl;
+ cout << age << " ! Boy are you old!\n";
+ cout << " Did you know that you are at least " << days << " days old?\n\n";
}