diff options
Diffstat (limited to 'CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp')
| -rw-r--r-- | CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
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;
|