user7061: In the following code from an Arduino sketch will it run the first "for" statement before enacting the second "for" statement. Also how does it know go run the first stamens again? Will it continue to run till both statements are true? 
for(int r = 0; r < 8; r++){
    for(int c = 0; c < 8; c++){
        lc.setLed(0, r, c, HIGH);
    }
}


user10794: What you have there is a nested loop. The first for statement runs 8 times, incrementing r from 0 to 7. For each of those 8 iterations the second for statement runs, incrementing c from 0 to 7. Thus the setLed statement is executed 64 times.

Will it continue to run till both statements are true? 

Yes. Unless you have a break or return statement somewhere in the part of the code you haven't shown.
Strictly-speaking, a statement does not become true. They will run while the test inside the for remains true (both tests).
This is standard C++ or C programming. You may wish to consult a C tutorial if you find this sort of thing puzzling.

user4143: A for statement repeats everything between { and }, (or just the next line if there is no { and } a certain number of times.  It's not as simple as you might at first think, but it makes more sense if you write it out as a while loop explicitly.
For instance, for (a; b; c) { ... } could be re-written as:
a;
while (b) {
    c;
}

So if you had: 
for (int i = 0; i < 100; i++) { 
    Serial.println(i);
}

it could be re-written as:
int i = 0;
while (i < 100) {
    Serial.println(i);
    i++;
}

The two mean exactly the same thing.  A for has the three elements - initializer, comparison and iterator.  The initializer is run before the loop starts, the comparison is used to work out when the loop should finish, and the iterator is used to move through each iteration of the loop.
To re-write your specific example:
for(int r = 0; r < 8; r++){
    for(int c = 0; c < 8; c++){
        lc.setLed(0, r, c, HIGH);
    }
}

You would end up with:
int r = 0;
while (r < 8) {
    int c = 0;
    while (c < 8) {
        lc.setLed(0, r, c, HIGH);
        c++;
    }
    r++;
}

Now, if we were to do away with the loops altogether and write it all out longhand, what would it look like?  Well, let's start with the inner c loop.  That loops from 0 to 7 (while less than 8), so replacing that loop with 8 discrete calls to the function replacing c each time would end up with:
int r = 0;
while (r < 8) {
    lc.setLed(0, r, 0, HIGH);
    lc.setLed(0, r, 1, HIGH);
    lc.setLed(0, r, 2, HIGH);
    lc.setLed(0, r, 3, HIGH);
    lc.setLed(0, r, 4, HIGH);
    lc.setLed(0, r, 5, HIGH);
    lc.setLed(0, r, 6, HIGH);
    lc.setLed(0, r, 7, HIGH);
    r++;
}

We could take it a step further and unroll the outer r loop.  A subset of what you would end up with would be like this (note, I have skipped a lot of the middle ones):
lc.setLed(0, 0, 0, HIGH);
lc.setLed(0, 0, 1, HIGH);
lc.setLed(0, 0, 2, HIGH);
lc.setLed(0, 0, 3, HIGH);
lc.setLed(0, 0, 4, HIGH);
lc.setLed(0, 0, 5, HIGH);
lc.setLed(0, 0, 6, HIGH);
lc.setLed(0, 0, 7, HIGH);
lc.setLed(0, 1, 0, HIGH);
lc.setLed(0, 1, 1, HIGH);
... skipped a lot ...
lc.setLed(0, 6, 6, HIGH);
lc.setLed(0, 6, 7, HIGH);
lc.setLed(0, 7, 0, HIGH);
lc.setLed(0, 7, 1, HIGH);
lc.setLed(0, 7, 2, HIGH);
lc.setLed(0, 7, 3, HIGH);
lc.setLed(0, 7, 4, HIGH);
lc.setLed(0, 7, 5, HIGH);
lc.setLed(0, 7, 6, HIGH);
lc.setLed(0, 7, 7, HIGH);

There would, of course, be 8 × 8 = 64 entries in there.
for loops can be used in lots of other fun ways too.  It's not just a simple "run this X number of times".  For instance, you can loop through a C string until you reach the NULL character at the end of the string:
for (char *p = str; *p != 0; p++) {
    ... do something with *p
}

You can iterate through the entries in a linked list:
for (struct mylist *scan = myListHead; scan; scan = scan->next) {
    ... do something to scan->whatever ...
}

You can even embed functions in there:
for (char c = 0; c != '\n'; c = Serial.read()) {
    ... Do something with character `c` until `c` is a line feed ...
}

As you can see for is an incredibly powerful and flexible tool that is often overlooked in favour of the more explicit while.

7061: <p>In the following code from an Arduino sketch will it run the first "for" statement before enacting the second "for" statement. Also how does it know go run the first stamens again? Will it continue to run till both statements are true? </p>

<pre><code>for(int r = 0; r &lt; 8; r++){
    for(int c = 0; c &lt; 8; c++){
        lc.setLed(0, r, c, HIGH);
    }
}
</code></pre>
 10794: <p>What you have there is a nested loop. The first <code>for</code> statement runs 8 times, incrementing <code>r</code> from 0 to 7. For <em>each</em> of those 8 iterations the second <code>for</code> statement runs, incrementing <code>c</code> from 0 to 7. Thus the <code>setLed</code> statement is executed 64 times.</p>

<blockquote>
  <p>Will it continue to run till both statements are true? </p>
</blockquote>

<p>Yes. Unless you have a <code>break</code> or <code>return</code> statement somewhere in the part of the code you haven't shown.</p>

<p>Strictly-speaking, a <em>statement</em> does not become true. They will run while the test inside the <code>for</code> remains true (both tests).</p>

<p>This is standard C++ or C programming. You may wish to consult a C tutorial if you find this sort of thing puzzling.</p>
 4143: <p>A <code>for</code> statement repeats everything between <code>{</code> and <code>}</code>, (or just the next line if there is no <code>{</code> and <code>}</code> a certain number of times.  It's not as simple as you might at first think, but it makes more sense if you write it out as a <code>while</code> loop explicitly.</p>

<p>For instance, <code>for (a; b; c) { ... }</code> could be re-written as:</p>

<pre><code>a;
while (b) {
    c;
}
</code></pre>

<p>So if you had: </p>

<pre><code>for (int i = 0; i &lt; 100; i++) { 
    Serial.println(i);
}
</code></pre>

<p>it could be re-written as:</p>

<pre><code>int i = 0;
while (i &lt; 100) {
    Serial.println(i);
    i++;
}
</code></pre>

<p>The two mean exactly the same thing.  A <code>for</code> has the three elements - initializer, comparison and iterator.  The initializer is run before the loop starts, the comparison is used to work out when the loop should finish, and the iterator is used to move through each iteration of the loop.</p>

<p>To re-write your specific example:</p>

<pre><code>for(int r = 0; r &lt; 8; r++){
    for(int c = 0; c &lt; 8; c++){
        lc.setLed(0, r, c, HIGH);
    }
}
</code></pre>

<p>You would end up with:</p>

<pre><code>int r = 0;
while (r &lt; 8) {
    int c = 0;
    while (c &lt; 8) {
        lc.setLed(0, r, c, HIGH);
        c++;
    }
    r++;
}
</code></pre>

<p>Now, if we were to do away with the loops altogether and write it all out longhand, what would it look like?  Well, let's start with the inner <code>c</code> loop.  That loops from 0 to 7 (while less than 8), so replacing that loop with 8 discrete calls to the function replacing <code>c</code> each time would end up with:</p>

<pre><code>int r = 0;
while (r &lt; 8) {
    lc.setLed(0, r, 0, HIGH);
    lc.setLed(0, r, 1, HIGH);
    lc.setLed(0, r, 2, HIGH);
    lc.setLed(0, r, 3, HIGH);
    lc.setLed(0, r, 4, HIGH);
    lc.setLed(0, r, 5, HIGH);
    lc.setLed(0, r, 6, HIGH);
    lc.setLed(0, r, 7, HIGH);
    r++;
}
</code></pre>

<p>We could take it a step further and <em>unroll</em> the outer <code>r</code> loop.  A subset of what you would end up with would be like this (note, I have skipped a lot of the middle ones):</p>

<pre><code>lc.setLed(0, 0, 0, HIGH);
lc.setLed(0, 0, 1, HIGH);
lc.setLed(0, 0, 2, HIGH);
lc.setLed(0, 0, 3, HIGH);
lc.setLed(0, 0, 4, HIGH);
lc.setLed(0, 0, 5, HIGH);
lc.setLed(0, 0, 6, HIGH);
lc.setLed(0, 0, 7, HIGH);
lc.setLed(0, 1, 0, HIGH);
lc.setLed(0, 1, 1, HIGH);
... skipped a lot ...
lc.setLed(0, 6, 6, HIGH);
lc.setLed(0, 6, 7, HIGH);
lc.setLed(0, 7, 0, HIGH);
lc.setLed(0, 7, 1, HIGH);
lc.setLed(0, 7, 2, HIGH);
lc.setLed(0, 7, 3, HIGH);
lc.setLed(0, 7, 4, HIGH);
lc.setLed(0, 7, 5, HIGH);
lc.setLed(0, 7, 6, HIGH);
lc.setLed(0, 7, 7, HIGH);
</code></pre>

<p>There would, of course, be 8 × 8 = 64 entries in there.</p>

<p><code>for</code> loops can be used in lots of other fun ways too.  It's not just a simple "run this X number of times".  For instance, you can loop through a C string until you reach the NULL character at the end of the string:</p>

<pre><code>for (char *p = str; *p != 0; p++) {
    ... do something with *p
}
</code></pre>

<p>You can iterate through the entries in a linked list:</p>

<pre><code>for (struct mylist *scan = myListHead; scan; scan = scan-&gt;next) {
    ... do something to scan-&gt;whatever ...
}
</code></pre>

<p>You can even embed functions in there:</p>

<pre><code>for (char c = 0; c != '\n'; c = Serial.read()) {
    ... Do something with character `c` until `c` is a line feed ...
}
</code></pre>

<p>As you can see <code>for</code> is an incredibly powerful and flexible tool that is often overlooked in favour of the more explicit <code>while</code>.</p>
