Monday, February 8, 2010

What does the following program print?

int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

main()
{
int i;
for(i = 0; i < 3; i++)
 printf("%d%d%d", a[i][2-i], *a[i], *(*(a+i)+i));
}

 a) 3 1 1
     5 4 5
     7 7 9
 b) 7 1 1
    5 4 5
    3 7 9
 c) 3 1 1
    5 4 7
    7 7 9
 d) 3 5 7
    1 4 7
    1 7 9

No comments: