aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp
diff options
context:
space:
mode:
authorMorgan Cyrus <[email protected]>2022-10-12 21:15:43 -0700
committerMorgan Cyrus <[email protected]>2022-10-12 21:15:43 -0700
commit4428b7c14f3b3967ce7fbeca1e69bbbef2f8add8 (patch)
tree824713ecdd939b162f66e5f0c9e6ec05af70c5a8 /CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp
parentdone with step 7 (diff)
downloadcst116-chapter8-cyrus-4428b7c14f3b3967ce7fbeca1e69bbbef2f8add8.tar.xz
cst116-chapter8-cyrus-4428b7c14f3b3967ce7fbeca1e69bbbef2f8add8.zip
Fixed while look in Exercise 1
Diffstat (limited to 'CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp')
-rw-r--r--CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp b/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp
index 3adcc8d..bfab1d6 100644
--- a/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp
+++ b/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp
@@ -28,12 +28,22 @@
*
* 7) Why didn't the flow of the program return back to the while
* statement?
-* the while says while I is less than 0. Since i == 0, the while loop ends (i is 0, not less than 0)
+* there is a ; behind the while statement. Additionally the while says while I is less than 0. Since i == 0, the while loop ends (i is 0, not less than 0)
*
* 8) Fix this problem by removing the ; after the while statement.
+* done
*
* 9) Stop debugging and repeat Steps 2 � 5 to verify the correction
* worked.
+* done
+* set the while loop to:
+* while (i <= 0)
+ {
+ cout << i << endl;
+ }
+
+* This resolves the issue and the while loop executes.
+*
* 10) Stop debugging.
*
*/
@@ -86,8 +96,10 @@ int main()
// Breakpoint 1
// Put a breakpoint on the following line
- while (i < 0);
- cout << i << endl;
+ while (i <= 0)
+ {
+ cout << i << endl;
+ }
// Breakpoint 2
// Put a breakpoint on the following line