diff options
| author | Taylor Rogers <[email protected]> | 2022-10-08 14:30:11 -0700 |
|---|---|---|
| committer | Taylor Rogers <[email protected]> | 2022-10-08 14:30:11 -0700 |
| commit | 4084f1652ab41b263efd5c7777ee24e018a2563f (patch) | |
| tree | 1c0c3f240f8894f8dc0aead2e0d4d7325fe5472b /CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | |
| parent | Answered Q6 (diff) | |
| download | cst116-ch7-debugging-taylorrog-4084f1652ab41b263efd5c7777ee24e018a2563f.tar.xz cst116-ch7-debugging-taylorrog-4084f1652ab41b263efd5c7777ee24e018a2563f.zip | |
Answered exercise 2 Q6
Diffstat (limited to 'CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp')
| -rw-r--r-- | CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp index 8a7d023..10862be 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -29,8 +29,15 @@ * 3) Step over the if statement. Execution of the program should
* continue on the else if statement.
* 4) Verify that 25 is still stored in age.
+*
+* Still there
+*
+*
* 5) Step over the else if.
* 6) Why is the program going to print "Teenager" for an age of 25?
+*
+* because the OR operator was used when it should be an AND
+*
* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -61,9 +68,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;
|