Solution for Exercise 9-11

ex0911

#include <stdio.h>

int main()
{
    int alpha,code;

    for(alpha='A';alpha<='G';alpha=alpha+1)
    {
        for(code=1;code<=7;code=code+1)
        {
            printf("%c%d\t",alpha,code);
        }
        putchar('\n');      /* end a line of text */
    }
    return(0);
}

Notes

* Think of the outer loop (alpha) as rows. The inner loop (code) is columns.

* Another way to think of a nested loop is like a clock: The outer loop ticks once, like an hour. Then the inner, "nested" loop ticks off it's full count, like minutes. In my solution for Exercise 9-11, the outer loop ticks off 'A' first. Then the inner loop ticks from 1 through 7. Next, the outer loop ticks off 'B' and the inner loop repeats.