From 63c8702f524014bdc3deaa1c20bd38093f40f0c6 Mon Sep 17 00:00:00 2001 From: Trevor Bouchillon Date: Thu, 6 Oct 2022 18:54:07 -0700 Subject: Debug 1 complete --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (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 064a99e..6fb9e1c 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -34,6 +34,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? +* ************************************************************************************************************************ +* Because the compare operator is not correct. It needs to be && not ||. +* ************************************************************************************************************************ * 7) Fix the problem and repeat Steps 1 – 5 to verify the * problem was corrected. * 8) Stop debugging. @@ -64,9 +67,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; -- cgit v1.2.3