From 4428b7c14f3b3967ce7fbeca1e69bbbef2f8add8 Mon Sep 17 00:00:00 2001 From: Morgan Cyrus Date: Wed, 12 Oct 2022 21:15:43 -0700 Subject: Fixed while look in Exercise 1 --- CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp') 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 -- cgit v1.2.3