From 61c606c2931719c2414f5c23106dd46961af956d Mon Sep 17 00:00:00 2001 From: Joseph Williams Date: Thu, 6 Oct 2022 15:05:23 -0700 Subject: finished fixing buggy code --- CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp | 13 ++++++++++--- 1 file changed, 10 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 53e4a61..0c6e8d3 100644 --- a/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp +++ b/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp @@ -1,3 +1,10 @@ +// Answers: +// 1.7) Because the while loop has a semicolon that ends it, so the cout isn't actually in the while loop. +// 2.3) Because the while loop evaluates to false, because 0 is not less than 0. +// 2.4) See 2.3. +// 4.5) 10. +// 4.6) Nothing assigned 10 to count. Count was set to 0, then incremented by 1, 10 times. + /******************************************************************** * File: CST116-Ch8-Debugging.cpp * @@ -62,12 +69,12 @@ int main() // Breakpoint 1 // Put a breakpoint on the following line - while (i < 0); - cout << i << endl; + while (i < 10) + cout << i++ << endl; // Breakpoint 2 // Put a breakpoint on the following line - for (count = 0; count < 10; count++); + for (count = 0; count < 10; count++) cout << count << endl; return 0; -- cgit v1.2.3