Please, I need help in finding the sum of two matrices using pointers. Thanks.

Q: Do you know how to do it on paper?
(a) No: Go figure that out before trying to write code.
(b) Yes: Show us your code, and be more freaking specific about what problem you're having.

Since you didn't post any code, I'll assume your answer to the question is (a). All too often we get people who have no idea how to solve the problem and rush off to write code. It's like building a bridge without a blueprint. Stupid.

Q: Do you know how to do it on paper?
(a) No: Go figure that out before trying to write code.
(b) Yes: Show us your code, and be more freaking specific about what problem you're having.

Since you didn't post any code, I'll assume your answer to the question is (a). All too often we get people who have no idea how to solve the problem and rush off to write code. It's like building a bridge without a blueprint. Stupid.

I have tried but can't and that is why I brought it here

do 66 i=1,3
do 66 j=1,3

do 66 k=1,3
c[i,j] = a[i,k]  *   b[k,j]
66 continue

now convert to pointers

a[1,1]    in pointers      *(pa+0+0)

a[1,3] in pointers *(pa +(i-1) * 3*( j-1))

Assume matrices stored in column order
a[i,j]
1 1 *(pa)
2 1 *(pa + 2-1 + 3*(1-1) = *(pa+1)
3 1 *(pa + 3-1 + 3*(1-1) = *(pa+2)
1 2 *(pa + 1-1 + 3*(2-1) = *(pa+3)
2 2
3 2
1 3
2 3
3 3

I have tried but can't

Show us how much or whatever you have tried.
Before moving into such questions on programming, think how you would solve the problem sequencially.
Can you atleast do it without pointers, using array-index?

Assume matrices stored in column order

In C, 2D Arrays lements are stored in Row-major format. As per my knowledge, column-major is only used in Fotran and MATLAB (and this is the C forum)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.