diff options
| author | Morgan Cyrus <[email protected]> | 2022-10-12 21:15:43 -0700 |
|---|---|---|
| committer | Morgan Cyrus <[email protected]> | 2022-10-12 21:15:43 -0700 |
| commit | 4428b7c14f3b3967ce7fbeca1e69bbbef2f8add8 (patch) | |
| tree | 824713ecdd939b162f66e5f0c9e6ec05af70c5a8 /CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp | |
| parent | done with step 7 (diff) | |
| download | cst116-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.cpp | 18 |
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
|