From d135618af6d162965c0e7c2a17d3a4fb6bc8e424 Mon Sep 17 00:00:00 2001 From: Andrei F Date: Wed, 12 Oct 2022 21:48:20 -0700 Subject: Finished Exercise 1 --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 32 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 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..e2e7bbd 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -11,9 +11,16 @@ * 3) When prompted, enter your age. * 4) When the execution stops, add a watch on age and verify that * the value in age is what you typed in. + * + * Done, the age value is set to my input which is 19. + * * 5) Step over the if statement. * 6) Why did the value in age change? -* 7) Fix the problem and repeat Steps 2 – 5 to verify the + * + * The value of age changed because the if comparison were not correctly written, there was only a single = sign, + * which means that it would assign a value to a variable. + * +* 7) Fix the problem and repeat Steps 2 � 5 to verify the * problem was corrected. * 8) Stop debugging. * @@ -26,7 +33,10 @@ * 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? -* 7) Fix the problem and repeat Steps 1 – 5 to verify the + * + * The problem is that on the fi + * +* 7) Fix the problem and repeat Steps 1 � 5 to verify the * problem was corrected. * 8) Stop debugging. * 9) Remove Breakpoint1. @@ -56,18 +66,26 @@ 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) + } + else if (age < 12) { cout << "Child" << endl; - else if (age > 62) + } + else if (age > 62) { cout << "Senior" << endl; + } + // Breakpoint 2 // Put a breakpoint on the following line + else; - cout << "Adult" << endl; + { + cout << "Adult" << endl; + } return 0; } \ No newline at end of file -- cgit v1.2.3