diff options
| author | Trevor Bouchillon <[email protected]> | 2022-10-06 19:04:00 -0700 |
|---|---|---|
| committer | Trevor Bouchillon <[email protected]> | 2022-10-06 19:04:00 -0700 |
| commit | 909442f1cfc1402941e7f8b87f57f0788d39f8bc (patch) | |
| tree | 839e20a331d52b8dbb9d308c31e49b72220160bd /CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | |
| parent | debug 2 complete (diff) | |
| download | cst116-ch7-debugging-daboochillin-909442f1cfc1402941e7f8b87f57f0788d39f8bc.tar.xz cst116-ch7-debugging-daboochillin-909442f1cfc1402941e7f8b87f57f0788d39f8bc.zip | |
Debug 3 compelte
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 |