Advertisement
TheWhiteFang

[c] Two- dimensional arrays

Nov 11th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main()
  5. {
  6.     //array with 5 rows and 2 columns
  7.  
  8.     //int a [5][2] = {{0,0}, {0,1}, {2,9}, {4,7}, {9,5}  }; - actually equivalent
  9.     int a [5][2] = {{0,0},
  10.                     {0,1},
  11.                     {2,9},
  12.                     {4,7},
  13.                     {9,5}  };
  14.     int i, j;
  15.  
  16.     //output ea array element's value
  17.     for(i = 0 ;i < 5;i++){
  18.  
  19.         for(j = 0; j < 2; j++)
  20.         {
  21.             printf("numbers[%d][%d] =%d\n", i,j, a[i][j] );
  22.        
  23.         }
  24.    
  25.     }
  26.  
  27.  
  28.  
  29.  
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement