diff options
| author | Nathanturcas <[email protected]> | 2022-10-20 23:36:21 -0700 |
|---|---|---|
| committer | Nathanturcas <[email protected]> | 2022-10-20 23:36:21 -0700 |
| commit | 437473e3324531f055fc0806dcd9b62225856310 (patch) | |
| tree | 07e6f34d5da00206230212a7f0195fccc7c2ad18 /CST116-Ch7-Debugging | |
| parent | first commit. (diff) | |
| download | cst116-ch7-debugging-nathanturcas-main.tar.xz cst116-ch7-debugging-nathanturcas-main.zip | |
Diffstat (limited to 'CST116-Ch7-Debugging')
| -rw-r--r-- | CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index f64adfe..6506d45 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -38,7 +38,7 @@ * 3) Why does the program print both "Child" and "Adult"?
* 4) Re-run the program this time with debugging and run to
* Breakpoint 2.
-* 5) Why is the action with the else executing?
+* 5) Why is the action with the else executing? Because the semi colon met all the conditions, and Adult was not part of the else statement.
* 6) Fix the problem and re-run to verify the problem was corrected.
********************************************************************/
@@ -56,9 +56,9 @@ int main() // Breakpoint 1
// Put a breakpoint on the following line
- if (age = 1)
+ if (age == 1)
cout << "First Birthday" << endl;
- else if (age >= 12 || age <= 19)
+ else if (age >= 12 && age <= 19)
cout << "Teenager" << endl;
else if (age < 12)
cout << "Child" << endl;
@@ -66,8 +66,8 @@ 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 |