aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp
diff options
context:
space:
mode:
authorJoseph Williams <[email protected]>2022-10-06 15:05:23 -0700
committerJoseph Williams <[email protected]>2022-10-06 15:05:23 -0700
commit61c606c2931719c2414f5c23106dd46961af956d (patch)
tree636b16e8623a3f83b1c173f58fbfe8d604783e2f /CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp
parentInitial commit (diff)
downloadcst116-chapter8-debugging-allthenamesaretaken3141-main.tar.xz
cst116-chapter8-debugging-allthenamesaretaken3141-main.zip
finished fixing buggy codeHEADmain
Diffstat (limited to 'CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp')
-rw-r--r--CST116-Ch8-Debugging/CST116-Ch8-Debugging.cpp13
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;