IfIsLoop

Incorrect

The body of an if statement executes repeatedly, as long as the condition holds

Correct

The body of an if statement executes at most once

Correction
Here is what's right.

The body of an if-statement either executes, or it does not execute.

Students might mistake if-statements for while-statements.

Conditional: Execute body zero or one times


if (a > 0) {
    a = a - 1;
}
true
false
a > 0
a = a - 1
x

Loop: Execute body zero or more times

while (a > 0) {
    a = a - 1
}
true
false
a > 0
a = a - 1
x

Symptoms
How do you know your students might have this misconception?

  • Students claim an if-statement means “ensure that this condition holds”
  • Students claim an if-statement “corrects things whenever this condition does not hold”

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.