# Thread: Help with for loops and arrays

1. ## Help with for loops and arrays

Hi

I'm really new at C-programing so i would be very happy if someone could help me.

I have a project on C HW/SW where I am supposed to build a program for a VGA-display.

One of the things the program shall do is to print a letter on the display with one color and the rest of the screen with another color.

I only need 3 letters: A,B,C

so i thought that I could use Arrays built up on 1/0 to create the letter, like this.

insert
Code:
```
unsigned char a[8][8] = {
{0,0,0,1,1,0,0,0},
{0,0,1,0,0,1,0,0},
{0,1,0,0,0,0,1,0},
{0,1,0,0,0,0,1,0},
{0,1,1,1,1,1,1,0},
{0,1,0,0,0,0,1,0},
{0,1,0,0,0,0,1,0},
{0,1,0,0,0,0,1,0}
};```
1 symbolizes the letter A and shall be printed with a color
0 symbolizes the background and shall be printed with a background colour

As far as i understand it, I need 2 for loops for this
one that handles the one's and one that handles the zero's
and if it is 0 it shall be printed with a backgroundcolor and if it is 1 then it shall be printed with a colour

Now to my question. How do i write this code?
Do I have to write it in a different way because it is related to an array?
It seems to me as well that i need if statements?

Any help would be much appreciated=)

2. You can use two nested loops, where the outer one loops through the rows and the inner one the columns, where the counter variables represent the current row and column. Something like:
Code:
```int i, j;

for (i = 0; i < 8; ++i) {
for (j = 0; j < 8; ++j) {
switch (a[i][j]) {
case 0:
/* print color 1 */
break;
case 1:
/* print color 2 */
break;
default:
/* faulty data in the array */
break;
}
}
}```