Re: loops and arrays

  • From: "Littlefield, Tyler" <tyler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Wed, 17 Oct 2007 07:01:23 -0600

just print array[a][b] just like you assigned. then do tab. and then print the next. don't print newline until your inside loop is done.

Tyler Littlefield.
Vertigo head coder
"My programs don't have bugs, just randomly added features."
msn: tyler@xxxxxxxxxxxxx
email: tyler@xxxxxxxxxxxxx
aim: st8amnd2005
----- Original Message ----- From: "Daniel Dalton" <daniel.dalton47@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Tuesday, October 16, 2007 4:18 PM
Subject: loops and arrays


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++)
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
View the list's information and change your settings at //

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.14.12/1072 - Release Date: 10/15/2007 5:55 PM

View the list's information and change your settings at //

Other related posts: