//Accessing 2 dimensional array element through pointer.
This is the program.
Void main()
{
int a[3][3],i,j;
int *p;
clrscr();
printf("\n Enter the matrix elements\n);
for(i=0;i<3;i++)
for(j=0;j<3;j++)
scanf("%d",&a[i][j]);
p=&a[0][0];
printf("\n Matrix elements:\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%4d",*(p+3*i+j);
printf("\n");
}
}
In this program I'm not able to understand and trace the printing of array elements using the pointer.
Please Help. Why is the pointer incremented to 3 ... In fact I dont understand *(p+3*i+j) :( .... please help me in tracing the output.
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment