troubleshooting Question

# how to convert this program to &nbsp;pointer based multiplication

C
I wrote a program of simple 2D matrix multiplication is c.  Now I want to use pointer to solve this problem, which I am unable to do sofar.  I want to use pointer in function so that function will return me the pointer value(like using Malloc etc). Here is my original program which is working fine, but I am  need a pointer version of this program so that I can use pointer in function multmat. Please help me to recover it soon!

#include<stdio.h>
void matmult( int a1[][3], int b1[][4], int c1[][4]);
void matprint(int c2[][4]);
int main()
{
int a[2][3]={{1,3,4},
{2,0,1}},
b[3][4]={{1, 2, 3, 1},
{2, 2, 2, 2},
{3, 2, 1, 4}},
c[2][4]={{0, 0, 0, 0},
{0, 0, 0, 0}};
matmult(a,b,c);
matprint(c);
return 0;
}

// This function is used for Matrix multiplication
void matmult( int a1[][3], int b1[][4], int c1[][4])
{
int i,j,k;
for(i=0;i<2;i++)
{
for(j=0;j<4;j++)
{
for(k=0;k<3;k++)
{
c1[i][j]+=a1[i][k]*b1[k][j];
}
}
}
}

//This function is used to print the matrix product
void matprint(int c2[][4])
{
int i,j;
for(i=0;i<2;i++)
{
for(j=0;j<4;j++)
{
printf("%4d",c2[i][j]);
}
printf("\n");
}
}
cup
###### Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.