diff options
| author | Aaron Hill <[email protected]> | 2022-10-05 14:15:12 -0700 |
|---|---|---|
| committer | Aaron Hill <[email protected]> | 2022-10-05 14:15:12 -0700 |
| commit | 73a315aa4a59731b2364497c600ad08371904515 (patch) | |
| tree | 6fe36aea88d0f02a402c8362c6b5ec5c172dcd00 /CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | |
| parent | 1 (diff) | |
| download | cst116-ch7-debugging-hill-73a315aa4a59731b2364497c600ad08371904515.tar.xz cst116-ch7-debugging-hill-73a315aa4a59731b2364497c600ad08371904515.zip | |
beginning exercise 3
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 f64adfe..db15efc 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -13,6 +13,9 @@ * the value in age is what you typed in.
* 5) Step over the if statement.
* 6) Why did the value in age change?
+*
+* Syntax error. "if (age = 1)" attempts to set age to 1. "==" checks for equality.
+*
* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -26,6 +29,9 @@ * 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?
+*
+* Because the age is over 12.
+*
* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -56,9 +62,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;
|