How to read a multidimensional array?

This is a discussion on How to read a multidimensional array? within the C Programming forums, part of the General Programming Boards category; let's say numbers are 1 2 3 4 5 6 7 8 Code: i=0; j=0; for(i=0;i<4;j++) { arr[i]=i; } for ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    140

    How to read a multidimensional array?

    let's say numbers are

    1 2 3 4
    5 6 7 8

    Code:
    i=0;
    j=0;
    
    for(i=0;i<4;j++)
    {
      arr[i]=i;
    }
    
    for (j=0;j<4;j++)
    {
      arr[j]=j;
    }
    Is that the correct psuedocode?

  2. #2
    Registered User camel-man's Avatar
    Join Date
    Jan 2011
    Location
    Under the moon
    Posts
    637
    Multidimensional arrays are declared as int array[2][4] Where 2=rows, and 4= columns.

    So in your case you would want

    Code:
    int count=1;
    for(i=0;i<2;i++){
        for(j=0;j<4;j++)
            {
               arr[i][j]=count;
               count++;
            }
    }
    Last edited by camel-man; 11-06-2012 at 08:02 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 11-30-2010, 09:49 AM
  2. Help with MultiDimensional Array (I think)
    By RommelTJ in forum C Programming
    Replies: 5
    Last Post: 11-25-2009, 01:30 AM
  3. Copy multidimensional array to single array?
    By seepox in forum C Programming
    Replies: 9
    Last Post: 05-08-2006, 11:19 AM
  4. Multidimensional array: read errors?
    By eskog in forum C++ Programming
    Replies: 2
    Last Post: 05-11-2004, 12:11 AM
  5. multidimensional array
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 04-08-2002, 09:17 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21