From 8d2940adef6d2a4684a3f23b01a92489d0e61684 Mon Sep 17 00:00:00 2001 From: Andrei F Date: Wed, 12 Oct 2022 21:54:53 -0700 Subject: Finished exercise 3 --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (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 aa48b0c..bb7ed08 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -52,7 +52,15 @@ * 4) Re-run the program this time with debugging and run to * Breakpoint 2. * 5) Why is the action with the else executing? + * + * The action code inside the else block is executing because of the semicolon on the end of the "else", + * while I don't know why, I am assuming its because the ( compiler ? ) is assuming it's the end of a line and its + * automatically entering the block. Removing that semicolon will ensure that it won't execute. + * * 6) Fix the problem and re-run to verify the problem was corrected. + * + * If I input the age 19 now, it will correctly output Teenager. + * ********************************************************************/ #include @@ -85,7 +93,7 @@ int main() // Breakpoint 2 // Put a breakpoint on the following line - else; + else { cout << "Adult" << endl; } -- cgit v1.2.3