Skip to content

Commit 188908e

Browse files
committed
Merge branch 'master' of https://github.com/bhoffman0/CSAwesome
2 parents b18ed36 + bdf70af commit 188908e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

_sources/Unit4-Iteration/topic-4-5-loop-analysis.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,11 @@ Did your trace table look like the following?
9595
:answer_d: var1 = 0, var2 = 2
9696
:answer_e: The loop will cause a run-time error with a division by zero
9797
:correct: b
98-
:feedback_a: The loop stops one of two ways, when var2 = 0 or when var1 / var2 = 0 - neither is true in this case
98+
:feedback_a: The loop stops one of two ways, when var2 = 0 or when var1 / var2 < 0 - neither is true in this case
9999
:feedback_b: The loop stopped because var2 = 0. After the first execution of the loop var1 = 1 and var2 = 1. After the second execution of the loop var1 = 2 and var2 = 0. This stops the loop and doesn't execute the second part of the complex conditional.
100-
:feedback_c: The loop stops one of two ways, when var2 = 0 or when var1 / var2 = 0 - neither is true in this case
101-
:feedback_d: The loop stops one of two ways, when var2 = 0 or when var1 / var2 = 0 - neither is true in this case
102-
:feedback_e: Even though var1 = 2 and var2 = 0 when the conditional is executed the first condition is true so the rest of the complex conditional won't execute.
100+
:feedback_c: The loop stops one of two ways, when var2 = 0 or when var1 / var2 < 0 - neither is true in this case
101+
:feedback_d: The loop stops one of two ways, when var2 = 0 or when var1 / var2 < 0 - neither is true in this case
102+
:feedback_e: This does not cause a run-time error because the loop stops before the division by zero would occur because of short-circuit evaluation where the first condition in the && is false when var2 is 0, so the second condition is not executed.
103103

104104
What are the values of var1 and var2 when the code finishes executing?
105105

@@ -111,7 +111,7 @@ Did your trace table look like the following?
111111
while ((var2 != 0) && ((var1 / var2) >= 0))
112112
{
113113
var1 = var1 + 1;
114-
var2 = var2 -1;
114+
var2 = var2 - 1;
115115
}
116116
117117
.. mchoice:: qlb_2_3

0 commit comments

Comments
 (0)