From 909442f1cfc1402941e7f8b87f57f0788d39f8bc Mon Sep 17 00:00:00 2001 From: Trevor Bouchillon Date: Thu, 6 Oct 2022 19:04:00 -0700 Subject: Debug 3 compelte --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index 9db265a..c67ba7b 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -47,9 +47,16 @@ * 1) Run the program without debugging. * 2) When prompted, enter the value of 10 for your age. * 3) Why does the program print both "Child" and "Adult"? +* ************************************************************************************************************************ +* Because the else statement has a semicolon at the end of it, so its not actually executing amything that else statement includes, because it doesn't include anything +* Deleting that semicolon makes the print out of adult part of the else statement. Otherwise its just always going to print adult. +* ************************************************************************************************************************ * 4) Re-run the program this time with debugging and run to * Breakpoint 2. * 5) Why is the action with the else executing? +* ************************************************************************************************************************ +* Becuase the age entered does not fall within any of the if statement. +* ************************************************************************************************************************ * 6) Fix the problem and re-run to verify the problem was corrected. ********************************************************************/ @@ -77,8 +84,7 @@ 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