diff options
| author | huntbyrne <[email protected]> | 2022-10-18 12:46:44 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-10-18 12:46:44 -0700 |
| commit | 6215090b71db34067fddbfe95f4a0a706de8331d (patch) | |
| tree | 1c939c688673c1719d0b763797eb0d0f747a0ac5 | |
| parent | Initial commit (diff) | |
| download | cst116-chapter8-debugging-huntbyrne-6215090b71db34067fddbfe95f4a0a706de8331d.tar.xz cst116-chapter8-debugging-huntbyrne-6215090b71db34067fddbfe95f4a0a706de8331d.zip | |
Update CST116-Ch8-Debugging.cpp
| -rw-r--r-- | CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp b/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp index 53e4a61..34615f6 100644 --- a/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp +++ b/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp @@ -13,9 +13,9 @@ * 5) The execution continues to the cout statement as expected.
* 6) Step over the cout statement.
* 7) Why didn't the flow of the program return back to the while
-* statement?
+* statement? // Answer: After the While Statement the ; automatically sets i as below 0
* 8) Fix this problem by removing the ; after the while statement.
-* 9) Stop debugging and repeat Steps 2 � 5 to verify the correction
+* 9) Stop debugging and repeat Steps 2 – 5 to verify the correction
* worked.
* 10) Stop debugging.
*
@@ -23,11 +23,11 @@ *
* 1) Run to Breakpoint 1.
* 2) Step into the while loop.
-* 3) Why did the cout not execute?
+* 3) Why did the cout not execute? // Answer: Missing STD command and also i was not greater than 0
* 4) Check the value of i, now check the condition, does the
* condition evaluate to true?
* 5) Change the "< 0" to a "< 10".
-* 6) Stop debugging and repeat Steps 1 � 4 to verify the correction
+* 6) Stop debugging and repeat Steps 1 – 4 to verify the correction
* worked.
* 7) Stop debugging.
*
@@ -39,7 +39,7 @@ * 4) Fix the problem by adding a "++" after the i in the cout
* statement.
* 5) Run the program to Breakpoint 2 and verify that the output
-* displayed on the screen is 0 � 9.
+* displayed on the screen is 0 – 9.
*
* Debugging Exercise 4
*
@@ -47,8 +47,8 @@ * 2) Add a watch to the variable count.
* 3) Verify that the contents of count is garbage.
* 4) Step into the loop.
-* 5) What is the value stored in count now?
-* 6) Where was 10 assigned to count?
+* 5) What is the value stored in count now? // Answer: 10
+* 6) Where was 10 assigned to count? // Answer: With "count++" it shows the highest value between 0 and 10.
* 7) Fix the problem and re-run to verify.
********************************************************************/
#include <iostream>
@@ -62,8 +62,8 @@ int main() // Breakpoint 1
// Put a breakpoint on the following line
- while (i < 0);
- cout << i << endl;
+ while (i < 10)
+ std::cout << i++ << endl;
// Breakpoint 2
// Put a breakpoint on the following line
|