Hardware Reference
In-Depth Information
Figure 5-1. This flow chart is another way of showing how a for loop works.
In the for loop above, you'll notice that the loop iterated 3
times, but it only counted up to the number 2. As a typical
convention in programming, you start counting from the num-
ber 0. Therefore, a list with 10 items would be numbered 0
through 9.
The most common way that a for loop is used is to have a particular block
of code run a specific number of times. You'll therefore see a for loop like this
quite frequently:
for (int i = 0; i < 10; i++) {
// This will be executed 10 times
}
 
Search WWH ::




Custom Search