## loops and arrays

• From: Daniel Dalton <daniel.dalton47@xxxxxxxxx>
• To: programmingblind@xxxxxxxxxxxxx
• Date: Wed, 17 Oct 2007 08:18:56 +1000

```Hi,

Could someone help me out with this?
I have an array called array declared like this:
int array [5][4];
So I think this is called a multidimensional  array.

```
The book said I need to assign a random number to each array index. (Using the rand library function.
```In stlib.h)

I then have to print them to the screen.
In a table. From what I can understand 5 column's and 4 rows.
Should my code look something like this? It doesn't seem to work.
Could someone tell me where I am going wrong?

#include <stdio.h>
#include <stdlib.h>

int main ()
{
int array[5][4];
int a, b;

for(a =0; a < 5; a++)
{
for(b =0; b < 4; b++)
{
array [a][b] =rand ();
}
}

/*print them */
for(a =0; a <5; a++)
{
for(b =0; b < 4; b++)
{
/* I don't know what to do with this part.*/

```
Can someone help me finish it off? I have know idea how to get them to print in the table.
```Is there any other problems?

And one more question:
How do loops inside other loops work?
If I wrote:
for(i =0; i <200; i++)
{
for(x =0; x < 10; x++)
{
/*code*/
}
}
```
So would the loop with x (the loop inside the first loop) be executed while the first loop is true?
```So while the first loop is executing would
it run the whole second loop for one increment of I.
so would the second loop count up to 9 for every increment of i?

Thanks for any help.

--
Daniel Dalton

http://members.iinet.net.au/~ddalton/
daniel.dalton47@xxxxxxxxx
__________
```
View the list's information and change your settings at http://www.freelists.org/list/programmingblind
```
```