diff options
Diffstat (limited to 'CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp')
| -rw-r--r-- | CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 10 |
1 files 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 |