From 3138e6bce864466472fff7dd6295b2705492fcf1 Mon Sep 17 00:00:00 2001 From: Morgan Cyrus Date: Wed, 12 Oct 2022 20:36:59 -0700 Subject: Added {} brackets to all of the statements. --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 19 +++++++++++++++++-- 1 file changed, 17 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 6663f38..fd649e1 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -68,9 +68,14 @@ * Debugging Exercise 3 * * 1) Run the program without debugging. +* done * * 2) When prompted, enter the value of 10 for your age. +* done +* * 3) Why does the program print both "Child" and "Adult"? +* the brackets {} were left out for the if, else if, and else statements. +* * 4) Re-run the program this time with debugging and run to * Breakpoint 2. * 5) Why is the action with the else executing? @@ -92,17 +97,27 @@ int main() // Breakpoint 1 // Put a breakpoint on the following line if (age == 1) + { cout << "First Birthday" << endl; + } else if (age >= 12 && age <= 19) + { cout << "Teenager" << endl; + } else if (age < 12) + { cout << "Child" << endl; + } else if (age > 62) + { 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