**Precedence Summary**

Let’s summarize the precedence situation for the operators we’ve seen so far. The operators higher on the list have higher precedence than those lower down/Operators with higher precedence are evaluated before those with lower precedence. Operators on the same row have equal precedence. You can force an expression to be evaluated first by placing parentheses around it.

**Figure 3.16 **Operation of the break statement.

To demonstrate break, here’s a program, showprim, that displays the distribution of prime numbers in graphical form:

In effect every position on an 80-column by 25-line console screen is numbered, from 0 to 1999 (which is 80*25-1). If the number at a particular position is prime, the position is colored white; if it’s not prime, it’s colored gray.

Figure 3.17 shows the display Strictly speaking, 0 is not considered a prime, but itfc shown as white to avoid complicating the program. Think of the columns across the top as being numbered from 0 to 79. Notice that no primes (except 21 appear in even-numbered columns, since they’re all divisible by 2. Is there a pattern to the other numbers? The world of mathematics will be very excited if you find a pattern that allows you to predict whether any given number is prime. When the inner for loop determines that a number is not prime, it sets the character ch to GRAY, and then executes break to escape from the inner loop. (We don’t want to exit from the entire program, as iathe prime example, since we have a whole series of numbers to work on.)

Notice that break only takes you out of the innermost loop. This is true no matter what constructions are nested inside each other: break only takes you out of the construction in which it’s embedded. If there were a switch within a loop, a break in the switch would only take you out of the switch, not out of the loop. The last cout statement prints the graphics character, and then the loop continues, testing the next number for primeness.

### Related Programming Assignments