From 6035d6df3d568b79353b0f91bcf4b93a992a7ab5 Mon Sep 17 00:00:00 2001 From: Joe Traver Date: Tue, 11 Oct 2022 21:10:55 -0700 Subject: Answered question for exercise 2 and made correction --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index a6a94ba..d395096 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -29,6 +29,9 @@ * 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? +* +* -The operator is "or" (||) but should be "and" (&&) to require both conditions being met to produce that output- +* * 7) Fix the problem and repeat Steps 1 – 5 to verify the * problem was corrected. * 8) Stop debugging. @@ -63,7 +66,7 @@ int main() 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) -- cgit v1.2.3