First page Back Continue Last page Graphics
Arrays and Loops
Loops are often used to “iterate” through an array.
BE CAREFUL that you don't run off the end of the array.
Good:
- int array[10];
- for ( int i = 0; i < 10; i++) array [ i ] = 0;
Bad:
- int array[10];
- for ( int i = 0; i <= 10; i++) array [ i ] = 0;