diff options
| author | JonCr <[email protected]> | 2022-10-22 17:23:19 -0700 |
|---|---|---|
| committer | JonCr <[email protected]> | 2022-10-22 17:23:19 -0700 |
| commit | 115b3cd2640c61b20bd6c2e010ea1ad34ab95aba (patch) | |
| tree | 2c6af2863452428124bd301ce924e2e840c6c6a8 | |
| parent | Adding gitignore (diff) | |
| download | cst116-ch9-debugging-cognitiveshadow-115b3cd2640c61b20bd6c2e010ea1ad34ab95aba.tar.xz cst116-ch9-debugging-cognitiveshadow-115b3cd2640c61b20bd6c2e010ea1ad34ab95aba.zip | |
| -rw-r--r-- | CST116-Ch9-Crombie-pseudocode.txt | 16 | ||||
| -rw-r--r-- | CST116-Ch9-Crombie.txt | 7 | ||||
| -rw-r--r-- | CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp | 7 |
3 files changed, 28 insertions, 2 deletions
diff --git a/CST116-Ch9-Crombie-pseudocode.txt b/CST116-Ch9-Crombie-pseudocode.txt new file mode 100644 index 0000000..12721a7 --- /dev/null +++ b/CST116-Ch9-Crombie-pseudocode.txt @@ -0,0 +1,16 @@ +Set DAYS_PER_YEAR equal to 365 +Declare functions +Start main function +Set age equal to 0 +Set days equal to 0 +Run GetAge function + Print "Please enter your age: " + Input age +Set age equal to input value +Run CalcDays function + Give age the alias "years" + Set days equal to years multiplied by DAYS_PER_YEAR +Set days equal to result +Run PrintResults + Print age and "! Boy are you old!" + Print "Did you know that you are at least " days " days old?"
\ No newline at end of file diff --git a/CST116-Ch9-Crombie.txt b/CST116-Ch9-Crombie.txt new file mode 100644 index 0000000..cf24f2c --- /dev/null +++ b/CST116-Ch9-Crombie.txt @@ -0,0 +1,7 @@ +Please enter your age: 20 +20! Boy are you old! +Did you know that you are at least 7300 days old? + + +C:\Users\JonCr\source\repos\cst116-ch9-debugging-CognitiveShadow\CST116-Ch9-Debugging\x64\Debug\CST116-Ch9-Debugging.exe (process 20256) exited with code 0. +Press any key to close this window . . . diff --git a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp index eff8980..7f10a3e 100644 --- a/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp +++ b/CST116-Ch9-Debugging/CST116-Ch9-Debugging.cpp @@ -12,6 +12,7 @@ * 4) Add another watch using &age for the name. This will display
* the address of age.
* 5) Write down the address of age.
+* 0x000000674baffca4 {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.
@@ -36,6 +37,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?
+* It is given the alias "years"
* 6) Stop debugging.
*
* Debugging Exercise 3
@@ -47,6 +49,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?
+* age and days were swapped around.
* 7) Stop debugging and fix the error.
*
* Debugging Exercise 4
@@ -77,7 +80,7 @@ int main() // Breakpoint 1
// Put breakpoint on the following line
- GetAge();
+ age = GetAge();
days = CalcDays(age);
// Breakpoint 2
@@ -103,7 +106,7 @@ int CalcDays(int years) 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";
|