From 4084f1652ab41b263efd5c7777ee24e018a2563f Mon Sep 17 00:00:00 2001 From: Taylor Rogers Date: Sat, 8 Oct 2022 14:30:11 -0700 Subject: Answered exercise 2 Q6 --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 11 +++++++++-- 1 file changed, 9 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 8a7d023..10862be 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -29,8 +29,15 @@ * 3) Step over the if statement. Execution of the program should * continue on the else if statement. * 4) Verify that 25 is still stored in age. +* +* Still there +* +* * 5) Step over the else if. * 6) Why is the program going to print "Teenager" for an age of 25? +* +* because the OR operator was used when it should be an AND +* * 7) Fix the problem and repeat Steps 1 – 5 to verify the * problem was corrected. * 8) Stop debugging. @@ -61,9 +68,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