diff options
| author | Trenton Stark <[email protected]> | 2022-10-12 20:59:46 -0700 |
|---|---|---|
| committer | Trenton Stark <[email protected]> | 2022-10-12 20:59:46 -0700 |
| commit | 4974d1e9b7bc166cb13838730b1e1368bf0d0f77 (patch) | |
| tree | d481af96cec75f8e18367c39480dc93e87e85a43 | |
| parent | completed exercise 1 (diff) | |
| download | cst116-ch7-debugging-stark-4974d1e9b7bc166cb13838730b1e1368bf0d0f77.tar.xz cst116-ch7-debugging-stark-4974d1e9b7bc166cb13838730b1e1368bf0d0f77.zip | |
completed exercise 2
| -rw-r--r-- | CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index 19d0109..538fb8d 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -27,6 +27,7 @@ * 4) Verify that 25 is still stored in age.
* 5) Step over the else if.
* 6) Why is the program going to print "Teenager" for an age of 25?
+* Else if must fulfill either of the two clauses, in this case 25 is >= 12
* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -59,7 +60,7 @@ int main() // Put a breakpoint on the following line
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;
|