Home
 
 
Search:  
C C++ Perl PHP Python HTML ShellScripts
 
 
  Coding Books
  Tutorials
  Search Code
  Browse Code
  Link to Us
  Site News
  Contact Metalshell
 
 
 
  Submit Code   Statistics
 



Standard C Library, The    (ISBN: 0131315099)


 

 List Price: $53.00
 Our Price: $53.00
 Used Price: $26.70

 Release Date: 01 July, 1991
 Manufacturer: Prentice Hall PTR (Paperback)
 Sales Rank: 60,769

 Author: P. J. Plauger









More Info

 Multidimensional Arrays 2001-12-06 02:49:10
 
Category: source:c:strings
Description: Example of multidimensional arrays in c
Platform: unix
Author: detour
Viewed: 7111
Rating: 2.9/5 (40 votes)
If you have any questions about this piece of code or still need help, try posting your question on the forum.

 

Printable Version
multiarry.c
/* multiarry.c written by detour@metalshell.com
 *
 * simple example of multidimensional arrays
 *
 * http://www.metalshell.com/
 *
 */

#include <stdio.h>

int main() {
  int x, y;

  /* A multidimensional array can be thought of as an array
   * inside an array.  The declaration of grid is making 3 arrays
   * of size 2.
   */
  int grid[3][2] = { {10,20},{30,40},{50,60} };

  /* The table of grid looks like
   *    ---------
   *  0| 10 | 20 |
   *  1| 30 | 40 |
   *  2| 50 | 60 |
   *    ---------
   *      0    1
   *
   */

  
  for (x=0;x<3;x++) 
    for (y=0;y<2;y++) {
      printf("row = %i\ncol = %i\nvalue = %i\n", x, y, grid[x][y]);
    }

}
Rate this code:
(Not Helpful)  (Very Helpful) 

 
 
   Developer.*  
   Blue Parrots  
   Technipal  
   Defy Magazine  
   Code Project  
   Prog. Heaven  


Got Money?