From 634dca05ca695c127c1dd80aabec7d29eb489bf7 Mon Sep 17 00:00:00 2001 From: Andrei F Date: Wed, 12 Oct 2022 21:50:18 -0700 Subject: Finished exercise 2 --- CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp | 7 +++++-- 1 file changed, 5 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 e2e7bbd..aa48b0c 100644 --- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp +++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp @@ -18,7 +18,8 @@ * 6) Why did the value in age change? * * 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. + * which means that it would assign a value to a variable. Additionally, the brackets to the if statements were + * missing and I added them. * * 7) Fix the problem and repeat Steps 2 � 5 to verify the * problem was corrected. @@ -34,7 +35,9 @@ * 5) Step over the else if. * 6) Why is the program going to print "Teenager" for an age of 25? * - * The problem is that on the fi + * The problem is that on the first else if statement, it was using the OR ( || ) comparison, and that means that + * any input age is going to be more than 12 OR less than or equal to 19, therefore any age input is going to result + * in teenager. * * 7) Fix the problem and repeat Steps 1 � 5 to verify the * problem was corrected. -- cgit v1.2.3