# populating two dimensional arrays

• 04-05-2002
garycastillo
populating two dimensional arrays
:confused:
I have an assignment that requires me to populate a two dimensioanl array and then use it to prepare a summary based on that array.
Ex. three stores each have three products, have the user input the total of each product for each store and then have the program list that information.

As far as I have gotten is this code for populating the array:

int iar[3][4]
for (rown=0;rown<3;j++)
for(coln=0;coln<4;k++)
printf("enter element ar[%d][%d]",rown, coln);
scanf("%d",&iar[rown][coln]);

If i could just get somebody to show me a complete program that populates a two dimensional array and then lists that information, I could finish the rest of the program.

Thanks to anybody that can help
• 04-05-2002
quzah
Code:

```int x, y, array[3][4]; for( y = 0; y < 4; y++ )for( x = 0; x < 3; x++ ) {     printf( "Enter a value for array[%d][%d]: ", x, y );     scanf( "%d", array[x][y] ); } for( y = 0; y < 4; y++ )for( x = 0; x < 3; x++ ) {     printf( "The value of array[%d][%d]: is %d.\n", x, y, array[x][y] ); }```
Enjoy.

Quzah.
• 04-05-2002
Prelude
Code:

```for( y = 0; y < 4; y++ )for( x = 0; x < 3; x++ ) {     printf( "Enter a value for array[%d][%d]: ", x, y );     scanf( "%d", array[x][y] ); }```
That's an interesting implementation of nested loops. Kind of scary too. ;)

-Prelude