aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDoolyBoi <[email protected]>2022-10-12 18:08:53 -0700
committerDoolyBoi <[email protected]>2022-10-12 18:08:53 -0700
commitf36d8da94895fab43bbcd32610ece2f8c8d828e9 (patch)
treeae476207a6132ffa2833028e8db30625b2ee4773
parentchanged name (diff)
downloadcst116-ch7-debugging-abd00l4h-f36d8da94895fab43bbcd32610ece2f8c8d828e9.tar.xz
cst116-ch7-debugging-abd00l4h-f36d8da94895fab43bbcd32610ece2f8c8d828e9.zip
fixed issues from debugging exercise 1 and 2
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp b/CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp
index 2cd1c90..5ce574f 100644
--- a/CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp
+++ b/CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp
@@ -13,6 +13,8 @@
* the value in age is what you typed in.
* 5) Step over the if statement.
* 6) Why did the value in age change?
+* The evaluation in the if statement makes it so that age is set to 1 and doesn't check if age is 1
+* basically do "==" not "="
* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -26,6 +28,7 @@
* 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?
+* If the age is greater than equal to 12 or less than equal 19 it will classify the age as teenager. It should be if age is greater than equal to 12 and less than equal to 19
* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -56,9 +59,9 @@ 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)
cout << "Child" << endl;