# Matrix Arrays

This is a discussion on Matrix Arrays within the C Programming forums, part of the General Programming Boards category; I need to write a program which uses a pointer to access the elemnts of an array A and an ...

1. ## Matrix Arrays

I need to write a program which uses a pointer to access the elemnts of an array A and an array B (which is the transpose of A) this is what i have so far, but how would i set up the pointer to print an element from each of these matrices?
Thanx

Code:
```#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <string.h>

main()
{
long int A[3][4] = 	{1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12};
long int B[4][3] =	{1, 5, 9,
2, 6, 10,
3, 7, 11,
4, 8, 12};
printf ("%i %i %i\n", B[0][0], B[0][1], B[0][2]);
printf ("%i %i %i\n", B[1][0], B[1][1], B[1][2]);
printf ("%i %i %i\n", B[2][0], B[2][1], B[2][2]);
printf ("%i %i %i\n", B[3][0], B[3][1], B[3][2]);

long int *ptr
}```

2. Code:
```for(ptr = A;ptr - A < 3*4;ptr++)
printf("%i\n", *ptr);```

3. No this just prints out every value from the matrix. I need the pointer to print out the elements A[1][3] and B[1][0]. Is this possible?

4. Code:
```ptr = &A[1][3];
printf("%i\n", *ptr);```
Repeat for B[1][0].
Is this possible?
Why would your instructor give you an assignment that was impossible?