From 437473e3324531f055fc0806dcd9b62225856310 Mon Sep 17 00:00:00 2001 From: Nathanturcas Date: Thu, 20 Oct 2022 23:36:21 -0700 Subject: commit 2. --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 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 f64adfe..6506d45 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -38,7 +38,7 @@ * 3) Why does the program print both "Child" and "Adult"? * 4) Re-run the program this time with debugging and run to * Breakpoint 2. -* 5) Why is the action with the else executing? +* 5) Why is the action with the else executing? Because the semi colon met all the conditions, and Adult was not part of the else statement. * 6) Fix the problem and re-run to verify the problem was corrected. ********************************************************************/ @@ -56,9 +56,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; @@ -66,8 +66,8 @@ int main() cout << "Senior" << endl; // Breakpoint 2 // Put a breakpoint on the following line - else; - cout << "Adult" << endl; + else + cout << "Adult" << endl; return 0; } \ No newline at end of file -- cgit v1.2.3