From 73a315aa4a59731b2364497c600ad08371904515 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 5 Oct 2022 14:15:12 -0700 Subject: beginning exercise 3 --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp') 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; -- cgit v1.2.3