From 4974d1e9b7bc166cb13838730b1e1368bf0d0f77 Mon Sep 17 00:00:00 2001 From: Trenton Stark Date: Wed, 12 Oct 2022 20:59:46 -0700 Subject: completed exercise 2 --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp') diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index 19d0109..538fb8d 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -27,6 +27,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? +* Else if must fulfill either of the two clauses, in this case 25 is >= 12 * 7) Fix the problem and repeat Steps 1 – 5 to verify the * problem was corrected. * 8) Stop debugging. @@ -59,7 +60,7 @@ int main() // Put a breakpoint on the following line 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; -- cgit v1.2.3