aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
diff options
context:
space:
mode:
authorAndrei F <[email protected]>2022-10-12 21:48:20 -0700
committerAndrei F <[email protected]>2022-10-12 21:48:20 -0700
commitd135618af6d162965c0e7c2a17d3a4fb6bc8e424 (patch)
tree674389389d5f7f271d300a4b54fb99bedee87f10 /CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
parentAdding gitignore file (diff)
downloadcst116-ch7-debugging-florea-d135618af6d162965c0e7c2a17d3a4fb6bc8e424.tar.xz
cst116-ch7-debugging-florea-d135618af6d162965c0e7c2a17d3a4fb6bc8e424.zip
Finished Exercise 1
Diffstat (limited to 'CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp')
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
index f64adfe..e2e7bbd 100644
--- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
+++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
@@ -11,9 +11,16 @@
* 3) When prompted, enter your age.
* 4) When the execution stops, add a watch on age and verify that
* the value in age is what you typed in.
+ *
+ * Done, the age value is set to my input which is 19.
+ *
* 5) Step over the if statement.
* 6) Why did the value in age change?
-* 7) Fix the problem and repeat Steps 2 � 5 to verify the
+ *
+ * The value of age changed because the if comparison were not correctly written, there was only a single = sign,
+ * which means that it would assign a value to a variable.
+ *
+* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
*
@@ -26,7 +33,10 @@
* 4) Verify that 25 is still stored in age.
* 5) Step over the else if.
* 6) Why is the program going to print "Teenager" for an age of 25?
-* 7) Fix the problem and repeat Steps 1 � 5 to verify the
+ *
+ * The problem is that on the fi
+ *
+* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
* 9) Remove Breakpoint1.
@@ -56,18 +66,26 @@ int main()
// Breakpoint 1
// Put a breakpoint on the following line
- if (age = 1)
+ if (age == 1) {
cout << "First Birthday" << endl;
- else if (age >= 12 || age <= 19)
+ }
+ else if (age >= 12 && age <= 19) {
cout << "Teenager" << endl;
- else if (age < 12)
+ }
+ else if (age < 12) {
cout << "Child" << endl;
- else if (age > 62)
+ }
+ else if (age > 62) {
cout << "Senior" << endl;
+ }
+
// Breakpoint 2
// Put a breakpoint on the following line
+
else;
- cout << "Adult" << endl;
+ {
+ cout << "Adult" << endl;
+ }
return 0;
} \ No newline at end of file