diff options
| author | Joseph Williams <[email protected]> | 2022-10-05 16:35:29 -0700 |
|---|---|---|
| committer | Joseph Williams <[email protected]> | 2022-10-05 16:35:29 -0700 |
| commit | 181de10a9a15c6fe3ac564bea16fa59b25669b72 (patch) | |
| tree | 6977f97616a90a8d24f3d6a1766781181b4b5503 | |
| parent | Setting up GitHub Classroom Feedback (diff) | |
| download | cst116-ch7-debugging-allthenamesaretaken3141-181de10a9a15c6fe3ac564bea16fa59b25669b72.tar.xz cst116-ch7-debugging-allthenamesaretaken3141-181de10a9a15c6fe3ac564bea16fa59b25669b72.zip | |
completed debugging problems, still need to add run file
30 files changed, 101 insertions, 74 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a3204dd --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +################################################################################ +# This .gitignore file was automatically created by Microsoft(R) Visual Studio. +################################################################################ + +*.opendb diff --git a/.vs/cst116-ch7-debugging-AllTheNamesAreTaken3141/v17/.suo b/.vs/cst116-ch7-debugging-AllTheNamesAreTaken3141/v17/.suo Binary files differnew file mode 100644 index 0000000..a813db8 --- /dev/null +++ b/.vs/cst116-ch7-debugging-AllTheNamesAreTaken3141/v17/.suo diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/72d4d27d-d2e9-48be-9a1b-ce6fd240949d.vsidx b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/72d4d27d-d2e9-48be-9a1b-ce6fd240949d.vsidx Binary files differnew file mode 100644 index 0000000..d401a93 --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/72d4d27d-d2e9-48be-9a1b-ce6fd240949d.vsidx diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/ade4fe28-e275-480c-bef1-3f9eb7199433.vsidx b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/ade4fe28-e275-480c-bef1-3f9eb7199433.vsidx Binary files differnew file mode 100644 index 0000000..0d7fad0 --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/ade4fe28-e275-480c-bef1-3f9eb7199433.vsidx diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/read.lock b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/read.lock new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/FileContentIndex/read.lock diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/.suo b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/.suo Binary files differnew file mode 100644 index 0000000..a5dfa97 --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/.suo diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db Binary files differnew file mode 100644 index 0000000..f33d02b --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db-shm b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db-shm Binary files differnew file mode 100644 index 0000000..ed5358b --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db-shm diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db-wal b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db-wal new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/Browse.VC.db-wal diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/ipch/AutoPCH/28b5c3239c55cf83/CST116-CH7-DEBUGGING.ipch b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/ipch/AutoPCH/28b5c3239c55cf83/CST116-CH7-DEBUGGING.ipch Binary files differnew file mode 100644 index 0000000..238798c --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/ipch/AutoPCH/28b5c3239c55cf83/CST116-CH7-DEBUGGING.ipch diff --git a/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/ipch/AutoPCH/e5c9a56186ad915a/CST116-CH7-DEBUGGING-WILLIAMS.ipch b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/ipch/AutoPCH/e5c9a56186ad915a/CST116-CH7-DEBUGGING-WILLIAMS.ipch Binary files differnew file mode 100644 index 0000000..30eec25 --- /dev/null +++ b/CST116-Ch7-Debugging/.vs/CST116-Ch7-Debugging/v17/ipch/AutoPCH/e5c9a56186ad915a/CST116-CH7-DEBUGGING-WILLIAMS.ipch diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Williams.cpp index f64adfe..2a717ff 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging-Williams.cpp @@ -1,73 +1,79 @@ -/********************************************************************
-* File: CST116-Ch7-Debugging.cpp
-*
-* General Instructions: Complete each step before proceeding to the
-* next.
-*
-* Debugging Exercise 1
-*
-* 1) Insert a breakpoint on the lines indicated in the code.
-* 2) Run to Breakpoint 1.
-* 3) When prompted, enter your age.
-* 4) When the execution stops, add a watch on age and verify that
-* the value in age is what you typed in.
-* 5) Step over the if statement.
-* 6) Why did the value in age change?
-* 7) Fix the problem and repeat Steps 2 � 5 to verify the
-* problem was corrected.
-* 8) Stop debugging.
-*
-* Debugging Exercise 2
-*
-* 1) Run to Breakpoint 1.
-* 2) When prompted, enter the value 25 for your age.
-* 3) Step over the if statement. Execution of the program should
-* continue on the else if statement.
-* 4) Verify that 25 is still stored in age.
-* 5) Step over the else if.
-* 6) Why is the program going to print "Teenager" for an age of 25?
-* 7) Fix the problem and repeat Steps 1 � 5 to verify the
-* problem was corrected.
-* 8) Stop debugging.
-* 9) Remove Breakpoint1.
-*
-* Debugging Exercise 3
-*
-* 1) Run the program without debugging.
-* 2) When prompted, enter the value of 10 for your age.
-* 3) Why does the program print both "Child" and "Adult"?
-* 4) Re-run the program this time with debugging and run to
-* Breakpoint 2.
-* 5) Why is the action with the else executing?
-* 6) Fix the problem and re-run to verify the problem was corrected.
-********************************************************************/
-
-#include <iostream>
-using std::cout;
-using std::endl;
-using std::cin;
-
-int main()
-{
- int age = 0;
-
- cout << "Enter your age: ";
- cin >> age;
-
- // Breakpoint 1
- // Put a breakpoint on the following line
- if (age = 1)
- cout << "First Birthday" << endl;
- else if (age >= 12 || age <= 19)
- cout << "Teenager" << endl;
- else if (age < 12)
- cout << "Child" << endl;
- else if (age > 62)
- cout << "Senior" << endl;
- // Breakpoint 2
- // Put a breakpoint on the following line
- else;
- cout << "Adult" << endl;
-
- return 0;
+// ANSWERS: +// 1.6) The if statement uses =, instead of ==. == checks if two values are equal. = sets the first value to the second value. +// 2.6) The if statement for "teenager" uses ||, instead of &&. || is an OR operator and returns true if one or both conditions are true. && is an AND operator and returns true only if both conditions are true. +// 3.3) The cout statement that prints "Adult" isn't actually in the else statement, so it runs no matter what. +// 3.5) Because it's not actually in the else statement. + +/******************************************************************** +* File: CST116-Ch7-Debugging.cpp +* +* General Instructions: Complete each step before proceeding to the +* next. +* +* Debugging Exercise 1 +* +* 1) Insert a breakpoint on the lines indicated in the code. +* 2) Run to Breakpoint 1. +* 3) When prompted, enter your age. +* 4) When the execution stops, add a watch on age and verify that +* the value in age is what you typed in. +* 5) Step over the if statement. +* 6) Why did the value in age change? +* 7) Fix the problem and repeat Steps 2 � 5 to verify the +* problem was corrected. +* 8) Stop debugging. +* +* Debugging Exercise 2 +* +* 1) Run to Breakpoint 1. +* 2) When prompted, enter the value 25 for your age. +* 3) Step over the if statement. Execution of the program should +* continue on the else if statement. +* 4) Verify that 25 is still stored in age. +* 5) Step over the else if. +* 6) Why is the program going to print "Teenager" for an age of 25? +* 7) Fix the problem and repeat Steps 1 � 5 to verify the +* problem was corrected. +* 8) Stop debugging. +* 9) Remove Breakpoint1. +* +* Debugging Exercise 3 +* +* 1) Run the program without debugging. +* 2) When prompted, enter the value of 10 for your age. +* 3) Why does the program print both "Child" and "Adult"? +* 4) Re-run the program this time with debugging and run to +* Breakpoint 2. +* 5) Why is the action with the else executing? +* 6) Fix the problem and re-run to verify the problem was corrected. +********************************************************************/ + +#include <iostream> +using std::cout; +using std::endl; +using std::cin; + +int main() +{ + int age = 0; + + cout << "Enter your age: "; + cin >> age; + + // Breakpoint 1 + // Put a breakpoint on the following line + if (age == 1) + cout << "First Birthday" << endl; + else if (age >= 12 && age <= 19) + cout << "Teenager" << endl; + else if (age < 12) + cout << "Child" << endl; + else if (age > 62) + cout << "Senior" << endl; + // Breakpoint 2 + // Put a breakpoint on the following line + else + cout << "Adult" << endl; + + return 0; }
\ No newline at end of file diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj index 45b2819..c001452 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj @@ -127,7 +127,7 @@ </Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="CST116-Ch7-Debugging.cpp" />
+ <ClCompile Include="CST116-Ch7-Debugging-Williams.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters index a245946..fb28c2f 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.vcxproj.filters @@ -15,7 +15,7 @@ </Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="CST116-Ch7-Debugging.cpp">
+ <ClCompile Include="CST116-Ch7-Debugging-Williams.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.command.1.tlog b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.command.1.tlog Binary files differnew file mode 100644 index 0000000..94a1798 --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.command.1.tlog diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.read.1.tlog b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.read.1.tlog Binary files differnew file mode 100644 index 0000000..34c7b14 --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.read.1.tlog diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.write.1.tlog b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.write.1.tlog Binary files differnew file mode 100644 index 0000000..65ad306 --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CL.write.1.tlog diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CST116-Ch7-Debugging.lastbuildstate b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CST116-Ch7-Debugging.lastbuildstate new file mode 100644 index 0000000..02dd32a --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/CST116-Ch7-Debugging.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v143:VCToolArchitecture=Native64Bit:VCToolsVersion=14.33.31629:TargetPlatformVersion=10.0.19041.0: +Debug|x64|C:\Users\hey-t\Source\Repos\cst116-ch7-debugging-AllTheNamesAreTaken3141\CST116-Ch7-Debugging\| diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.command.1.tlog b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.command.1.tlog Binary files differnew file mode 100644 index 0000000..292538d --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.command.1.tlog diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.read.1.tlog b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.read.1.tlog Binary files differnew file mode 100644 index 0000000..3532140 --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.read.1.tlog diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.write.1.tlog b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.write.1.tlog Binary files differnew file mode 100644 index 0000000..34eae2b --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-C.b0d44148.tlog/link.write.1.tlog diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.exe b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.exe Binary files differnew file mode 100644 index 0000000..16fc92f --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.exe diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.exe.recipe b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.exe.recipe new file mode 100644 index 0000000..bdb139f --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.exe.recipe @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project> + <ProjectOutputs> + <ProjectOutput> + <FullPath>C:\Users\hey-t\Source\Repos\cst116-ch7-debugging-AllTheNamesAreTaken3141\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe</FullPath> + </ProjectOutput> + </ProjectOutputs> + <ContentFiles /> + <SatelliteDlls /> + <NonRecipeFileRefs /> +</Project>
\ No newline at end of file diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.ilk b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.ilk Binary files differnew file mode 100644 index 0000000..afd1fc9 --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.ilk diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.log b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.log new file mode 100644 index 0000000..f2210dd --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.log @@ -0,0 +1,2 @@ + CST116-Ch7-Debugging.cpp + CST116-Ch7-Debugging.vcxproj -> C:\Users\hey-t\Source\Repos\cst116-ch7-debugging-AllTheNamesAreTaken3141\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.obj b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.obj Binary files differnew file mode 100644 index 0000000..4818508 --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.obj diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.pdb b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.pdb Binary files differnew file mode 100644 index 0000000..a5d0f8d --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.pdb diff --git a/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.vcxproj.FileListAbsolute.txt b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..e55b704 --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/CST116-Ch7-Debugging.vcxproj.FileListAbsolute.txt @@ -0,0 +1 @@ +C:\Users\hey-t\Source\Repos\cst116-ch7-debugging-AllTheNamesAreTaken3141\CST116-Ch7-Debugging\x64\Debug\CST116-Ch7-Debugging.exe diff --git a/CST116-Ch7-Debugging/x64/Debug/vc143.idb b/CST116-Ch7-Debugging/x64/Debug/vc143.idb Binary files differnew file mode 100644 index 0000000..7162ec2 --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/vc143.idb diff --git a/CST116-Ch7-Debugging/x64/Debug/vc143.pdb b/CST116-Ch7-Debugging/x64/Debug/vc143.pdb Binary files differnew file mode 100644 index 0000000..e0ad88a --- /dev/null +++ b/CST116-Ch7-Debugging/x64/Debug/vc143.pdb |