I think that the book sample contain a bad code to demonstrate break use. The message with the answer cannot be after the loop, because the answer could not exist in the interval from 0 to 11. In this case, the message will be printed like:

Because 12 is the last value of i in the loop.

Remark: Is a best option write “A answer is %d”, once the equation can have two distinct integer roots.

The book example is OK because 10 is a root of the equation. For any equation without roots from 0 to 11, the program will fail with the wrong information that 12 is a root.

Remark: The values from 0 to 11 are referred as positive integers. The most accuracy will be non-negative integers, once zero is between the tested values.

I have created an generic example to found integer solutions in a given interval for a quadratic equation. As you can observe bellow, I use break when all two roots are found.

[code]/*

Find and print integer roots of a quadratic equation with coeficients a, b, and c:

ax^2 + bx + c = 0.

*/

void findIntegerRoots(int a, int b, int c, int from, int to) {

int rootIndex = 0;

```
printf("Integer roots of (%d)x^2 + (%d)x + (%d) = 0 in the interval [%d, %d]:\n",
a, b, c, from, to);
for (int x = from; x <= to; x++) {
if (a * x * x + b * x + c == 0) {
printf("x%d = %d\n", ++rootIndex, x);
if (rootIndex == 2) // The two roots are found.
break;
}
}
```

}

int main(int argc, const char * argv[])

{

findIntegerRoots(1, -1, -90, -100, 100);

```
return 0;
```

}[/code]

My sample use only the knowledge in the book until the break statement instructions.