#include <stdio.h>
void main() { int i, j, a[3][4] = {1,2,3,4,5,6,7,8,9,10,11,12}; for(i = 2; i >= 0; i = i  1) { for(j = 3; j >= 0; j = j  1) printf("a[%d][%d] = %d\t", i, j, a[i][j]); printf("\n"); } }

It is confusing isn't it? To make it clearer we can include another curly braces in the array declaration as shown below. The order of the element in the array won't change in this program. However how the elements displayed can be different.



#include <stdio.h>
void main() { int i, j; char a[3][4]; for(i = 0; i <= 2; i = i + 1) for(j = 0; j <= 3; j = j + 1) // scanf(" %c", &a[i][j]); scanf_s(" %c", &a[i][j], sizeof(a)); for(i = 0; i <= 2; i = i + 1) { for(j = 0; j <= 3; j = j + 1) printf("a[%d][%d] = %c\t", i, j, a[i][j]); printf("\n"); } }
Questions for the reading loop:
Questions for the printing loop.

Answers for the reading loop:
Answers for the printing loop:

#include <stdio.h>
void main() { int i, j; char a[3][4]; for(i = 0; i <= 3; i = i + 1) for(j = 0; j <= 2; j = j + 1) // scanf(" %c", &a[j][i]); scanf_s(" %c", &a[j][i], sizeof(a)); for(i = 0; i <= 2; i = i + 1) { for(j = 0; j <= 3; j = j + 1) printf("a[%d][%d] = %c\t", i, j, a[i][j]); printf("\n"); } }



#include <stdio.h>
void main() { int i, j; char a[3][4]; printf("Give three 3characters strings.\n"); for(i = 0; i <= 2; i = i + 1) // scanf("%s", &a[i]); scanf_s("%s", &a[i], 4); for(i = 0; i <= 2; i = i + 1) { for(j = 0; j <= 3; j = j + 1) printf("a[%d][%d] = %c\t", i, j, a[i][j]); printf("\n"); } }


#include <stdio.h>
void main() { int i, j, a[3][4]; for(i = 0; i <= 2; i = i + 1) { for(j = 0; j <= 3; j = j + 1) { a[i][j] = 7; printf("a[%d][%d] = %d\t", i, j, a[i][j]); } printf("\n"); } } 
In this program we assign or fill the array with integer 7. 
#include <stdio.h>
void main() { int i, j, a[3][4]; for(i = 0; i <= 2; i = i + 1) { for(j = 0; j <= 3; j = j + 1) { if(i == j) { a[i][j] = 7; printf("a[%d][%d] = %d\t", i, j, a[i][j]); } else { a[i][j] = 8; printf("a[%d][%d] = %d\t", i, j, a[i][j]); } } printf("\n"); } } 

In this program, if the i and j index are equal then fill an integer 7 and fill the rest with integer 8. 
#include <stdio.h>
void main() { int i, j; for(i = 1; i <= 3; i = i + 1) { for(j = 1; j <= 3; j = j + 1) printf("(%d  %d) = %d\t", i, j, i  j); printf("\n"); } } 
The array elements are the yields of the i  j or subtraction operations. 
#include <stdio.h>
void main() { int i, j; for(i = 1; i <= 3; i = i + 1) { for(j = 1; j <= i; j = j + 1) printf("(2 * %d  %d) = %d\t", i, j, 2 * i  j); printf("\n"); } } 
In this program the array element are the yields of the 2*ij operations while j <= i. 
int a[3][3] = {10, 20, 30, 40, 50, 60, 70, 80, 90};
#include <stdio.h>
void main() { int i, j; int a[3][3] = {10, 20, 30, 40, 50, 60, 70, 80, 90}; for(i = 0; i <= 2; i = i + 1) { for(j = 0; j <= 2; j = j + 1) printf("a[%d][%d] = %d\t", i, j, a[i][j]); printf("\n"); } } 

#include <stdio.h>
void main() { int i, j; int a[3][3] = {10, 20, 30, 40, 50, 60, 70, 80, 90}; for(i = 0; i <= 2; i = i + 1) { for(j = 0; j <= 2; j = j + 1) printf("a[%d][%d] = %d\t", j, i, a[j][i]); printf("\n"); } } 

#include <stdio.h>
void main() { int i, j; int a[3][3] = {10, 20, 30, 40, 50, 60, 70, 80, 90}; for(i = 0; i <= 2; i = i + 1) { for(j = 0; j <= 2; j = j + 1) printf("a[%d][2  %d] = %d ", i, j, a[i][2  j]); printf("\n"); } } 

#include <stdio.h>
void main() { int i, j; int a[3][3] = {10, 20, 30, 40, 50, 60, 70, 80, 90}; for(i = 0; i <= 2; i = i + 1) { for(j = 2; j >= 0; j = j  1) printf("a[2][%d] = %d\t", j, a[2][j]); printf("\n"); } } 
