diff options
| -rw-r--r-- | CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp b/CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp index 2cd1c90..5ce574f 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7Debugging-Havaldar.cpp @@ -13,6 +13,8 @@ * the value in age is what you typed in. * 5) Step over the if statement. * 6) Why did the value in age change? +* The evaluation in the if statement makes it so that age is set to 1 and doesn't check if age is 1 +* basically do "==" not "=" * 7) Fix the problem and repeat Steps 2 � 5 to verify the * problem was corrected. * 8) Stop debugging. @@ -26,6 +28,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? +* If the age is greater than equal to 12 or less than equal 19 it will classify the age as teenager. It should be if age is greater than equal to 12 and less than equal to 19 * 7) Fix the problem and repeat Steps 1 � 5 to verify the * problem was corrected. * 8) Stop debugging. @@ -56,9 +59,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; |