aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
diff options
context:
space:
mode:
authorWyatt <[email protected]>2022-12-02 11:41:42 -0800
committerWyatt <[email protected]>2022-12-02 11:41:42 -0800
commit5e4b060bda36e689369ee6497b0f57315f45b396 (patch)
tree76f42ace9c140e823388045066d454f78f80cdbd /CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-ch7-debugging-johnson-5e4b060bda36e689369ee6497b0f57315f45b396.tar.xz
cst116-ch7-debugging-johnson-5e4b060bda36e689369ee6497b0f57315f45b396.zip
assignment doneHEADmain
Diffstat (limited to 'CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp')
-rw-r--r--CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
index f64adfe..f024491 100644
--- a/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
+++ b/CST116-Ch7-Debugging/CST116-Ch7-Debugging.cpp
@@ -13,6 +13,7 @@
* the value in age is what you typed in.
* 5) Step over the if statement.
* 6) Why did the value in age change?
+* the if statement has an assignment for age. It isnt checking if age equals 1, it is setting age to 1.
* 7) Fix the problem and repeat Steps 2 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -26,6 +27,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?
+* age >= 12 is true when age is 25, the or statement doesnt check further and outputs Teenager.
* 7) Fix the problem and repeat Steps 1 � 5 to verify the
* problem was corrected.
* 8) Stop debugging.
@@ -36,9 +38,11 @@
* 1) Run the program without debugging.
* 2) When prompted, enter the value of 10 for your age.
* 3) Why does the program print both "Child" and "Adult"?
+* the else had a semicolon, which ended the statement.
* 4) Re-run the program this time with debugging and run to
* Breakpoint 2.
* 5) Why is the action with the else executing?
+* it wasnt inside the else.
* 6) Fix the problem and re-run to verify the problem was corrected.
********************************************************************/
@@ -56,9 +60,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;
@@ -66,8 +70,8 @@ int main()
cout << "Senior" << endl;
// Breakpoint 2
// Put a breakpoint on the following line
- else;
- cout << "Adult" << endl;
+ else
+ cout << "Adult" << endl;
return 0;
} \ No newline at end of file