From f31155764281276463dca9964a68875964dfe432 Mon Sep 17 00:00:00 2001 From: Bold Demchig Date: Wed, 12 Oct 2022 20:54:16 -0700 Subject: Hi. I have completed my Ch7 debugging and pushed to GitHub. I have been trying to push it couple times already. --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 97 +++++++++++---------- .../Debug/CST116-C.b0d44148.tlog/CL.command.1.tlog | Bin 0 -> 1002 bytes .../Debug/CST116-C.b0d44148.tlog/CL.read.1.tlog | Bin 0 -> 19792 bytes .../Debug/CST116-C.b0d44148.tlog/CL.write.1.tlog | Bin 0 -> 884 bytes .../CST116-Ch7-Debugging.lastbuildstate | 2 + .../CST116-C.b0d44148.tlog/link.command.1.tlog | Bin 0 -> 1760 bytes .../Debug/CST116-C.b0d44148.tlog/link.read.1.tlog | Bin 0 -> 3670 bytes .../Debug/CST116-C.b0d44148.tlog/link.write.1.tlog | Bin 0 -> 956 bytes .../Debug/CST116-Ch7-Debugging.exe | Bin 0 -> 50688 bytes .../Debug/CST116-Ch7-Debugging.exe.recipe | 11 +++ .../Debug/CST116-Ch7-Debugging.ilk | Bin 0 -> 539120 bytes .../Debug/CST116-Ch7-Debugging.obj | Bin 0 -> 71768 bytes .../Debug/CST116-Ch7-Debugging.pdb | Bin 0 -> 1806336 bytes ...T116-Ch7-Debugging.vcxproj.FileListAbsolute.txt | 1 + .../Debug/cst116-ch7-debugging.obj.enc | Bin 0 -> 71760 bytes CST116-Ch7-Debugging/Debug/vc143.idb | Bin 0 -> 166912 bytes CST116-Ch7-Debugging/Debug/vc143.pdb | Bin 0 -> 405504 bytes 17 files changed, 65 insertions(+), 46 deletions(-) create mode 100644 CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.command.1.tlog create mode 100644 CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.read.1.tlog create mode 100644 CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.write.1.tlog create mode 100644 CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CST116-Ch7-Debugging.lastbuildstate create mode 100644 CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.command.1.tlog create mode 100644 CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.read.1.tlog create mode 100644 CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.write.1.tlog create mode 100644 CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.exe create mode 100644 CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.exe.recipe create mode 100644 CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.ilk create mode 100644 CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.obj create mode 100644 CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.pdb create mode 100644 CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.vcxproj.FileListAbsolute.txt create mode 100644 CST116-Ch7-Debugging/Debug/cst116-ch7-debugging.obj.enc create mode 100644 CST116-Ch7-Debugging/Debug/vc143.idb create mode 100644 CST116-Ch7-Debugging/Debug/vc143.pdb (limited to 'CST116-Ch7-Debugging') diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index f64adfe..7c50bd8 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -6,68 +6,73 @@ * * 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? +* 1) Insert a breakpoint on the lines indicated in the code. Done +* 2) Run to Breakpoint 1. Done +* 3) When prompted, enter your age. Done +* 4) When the execution stops, add a watch on age and verify that Done +* the value in age is what you typed in. Yes. It is correct. +* 5) Step over the if statement. Done +* 6) Why did the value in age change? No. It should not change. +* * 7) Fix the problem and repeat Steps 2 – 5 to verify the -* problem was corrected. -* 8) Stop debugging. +* problem was corrected. Problem solved and commented at the spot +* 8) Stop debugging. Done * * Debugging Exercise 2 * -* 1) Run to Breakpoint 1. -* 2) When prompted, enter the value 25 for your age. +* 1) Run to Breakpoint 1. Done +* 2) When prompted, enter the value 25 for your age. Done * 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 +* continue on the else if statement. Yes. It does. +* 4) Verify that 25 is still stored in age. Yes. It is stored +* 5) Step over the else if. Done +* 6) Why is the program going to print "Teenager" for an age of 25? Because it used OR instead of AND. +* The both of conditions should be satisfied. +* So, I changed || into &&. +* 7) Fix the problem and repeat Steps 1 – 5 to verify the Done * problem was corrected. -* 8) Stop debugging. -* 9) Remove Breakpoint1. +* 8) Stop debugging. Done +* 9) Remove Breakpoint1. Done * * 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. -********************************************************************/ +* 1) Run the program without debugging. Yes, I did +* 2) When prompted, enter the value of 10 for your age. Yes, I did +* 3) Why does the program print both "Child" and "Adult"? Because of ; after else +* 4) Re-run the program this time with debugging and run to +* Breakpoint 2. Done +* 5) Why is the action with the else executing? ; means the end of the line and it stops right there. +* +* 6) Fix the problem and re-run to verify the problem was corrected. Done +*/ #include + using std::cout; using std::endl; using std::cin; -int main() -{ - int age = 0; +int main() { + + int age = 0; - cout << "Enter your age: "; - cin >> age; + cout << "Enter your age: " <> age; - // Breakpoint 1 - // Put a breakpoint on the following line - if (age = 1) - cout << "First Birthday" << endl; - else if (age >= 12 || age <= 19) + // Breakpoint 1 + // Put a breakpoint on the following line + if (age == 1) // In C++, == means equal, so I corrected it. + cout << "First Birthday" << endl; + else if (age >= 12 && age <= 19) // && should be used here not || 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; + else if (age < 12 && age > 1) + 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 + return 0; + } diff --git a/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.command.1.tlog b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.command.1.tlog new file mode 100644 index 0000000..f105298 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.command.1.tlog differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.read.1.tlog b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.read.1.tlog new file mode 100644 index 0000000..f9ae1a6 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.read.1.tlog differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.write.1.tlog b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.write.1.tlog new file mode 100644 index 0000000..501d51c Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CL.write.1.tlog differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CST116-Ch7-Debugging.lastbuildstate b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CST116-Ch7-Debugging.lastbuildstate new file mode 100644 index 0000000..ffca743 --- /dev/null +++ b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/CST116-Ch7-Debugging.lastbuildstate @@ -0,0 +1,2 @@ +PlatformToolSet=v143:VCToolArchitecture=Native32Bit:VCToolsVersion=14.33.31629:TargetPlatformVersion=10.0.19041.0: +Debug|Win32|C:\Users\batbo\Source\Repos\CST116\cst116-ch7-debugging-Batbold74\CST116-Ch7-Debugging\| diff --git a/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.command.1.tlog b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.command.1.tlog new file mode 100644 index 0000000..09249c2 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.command.1.tlog differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.read.1.tlog b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.read.1.tlog new file mode 100644 index 0000000..36236e9 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.read.1.tlog differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.write.1.tlog b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.write.1.tlog new file mode 100644 index 0000000..ccf2e79 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-C.b0d44148.tlog/link.write.1.tlog differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.exe b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.exe new file mode 100644 index 0000000..8819c18 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.exe differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.exe.recipe b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.exe.recipe new file mode 100644 index 0000000..1d45732 --- /dev/null +++ b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.exe.recipe @@ -0,0 +1,11 @@ + + + + + C:\Users\batbo\Source\Repos\CST116\cst116-ch7-debugging-Batbold74\CST116-Ch7-Debugging\Debug\CST116-Ch7-Debugging.exe + + + + + + \ No newline at end of file diff --git a/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.ilk b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.ilk new file mode 100644 index 0000000..aed61e7 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.ilk differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.obj b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.obj new file mode 100644 index 0000000..df5555f Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.obj differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.pdb b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.pdb new file mode 100644 index 0000000..86c1992 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.pdb differ diff --git a/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.vcxproj.FileListAbsolute.txt b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.vcxproj.FileListAbsolute.txt new file mode 100644 index 0000000..5f71896 --- /dev/null +++ b/CST116-Ch7-Debugging/Debug/CST116-Ch7-Debugging.vcxproj.FileListAbsolute.txt @@ -0,0 +1 @@ +C:\Users\batbo\Source\Repos\CST116\cst116-ch7-debugging-Batbold74\CST116-Ch7-Debugging\Debug\CST116-Ch7-Debugging.exe diff --git a/CST116-Ch7-Debugging/Debug/cst116-ch7-debugging.obj.enc b/CST116-Ch7-Debugging/Debug/cst116-ch7-debugging.obj.enc new file mode 100644 index 0000000..bc7306e Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/cst116-ch7-debugging.obj.enc differ diff --git a/CST116-Ch7-Debugging/Debug/vc143.idb b/CST116-Ch7-Debugging/Debug/vc143.idb new file mode 100644 index 0000000..1cddd08 Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/vc143.idb differ diff --git a/CST116-Ch7-Debugging/Debug/vc143.pdb b/CST116-Ch7-Debugging/Debug/vc143.pdb new file mode 100644 index 0000000..d482ede Binary files /dev/null and b/CST116-Ch7-Debugging/Debug/vc143.pdb differ -- cgit v1.2.3