Home › Forums › C Programming › matrix opreation in c

- This topic has 2 replies, 2 voices, and was last updated 8 years, 11 months ago by Anonymous.

- AuthorPosts
- June 26, 2012 at 8:43 am #2254AnonymousInactive
please solve this problem and reply as soon as possible….i will be wait for your answer…

Write a C program for the matrix operations. In particular,

write the following functions:a) Function

int ** allocMatrix(int m, int n)

that will allocates, using malloc, space for an mXn matrix.b) Function

void freeMatrix(int **a, int m)

to free up the memory allocated for an mXn matrix.

(Why do we not need “n” as an argument here?)c) Function

void readMatrix(int **a, int m, int n)

that reads an mXn matrix.d) Function

void printMatrix(int **a, int m, int n)

that prints an mXn matrixe) Function

int ** mulMatrix(int **a, int **b, int m, int n, int p)

that multiplies an mXn matrix with an nXp matrix. The

result is an mXp matrix.f) Function

int ** mul3Matrix(int **a, int **b, int **c,

int m, int n, int p, int q)

that multiplies 3 matrices a, b and c of sizes mXn,

nXp and pXq respectively.Use mulMatrix to compute intermediate result. Any

intermediate matrix should be freed once its use is over.Your main function should use these functions to read three matrices and

multiply them.A sample run is (user inputs should be obvious) :

$ ./a.out

enter the number m of rows of first matrix: 3

enter the number n of columns of first matrix/rows of second matrix: 2

enter the number n of columns of second matrix/rows of third matrix: 1

enter the number p of columns of third matrix: 2

enter the first matrix:

enter [0][0] th entry: 2

enter [0][1] th entry: 3

enter [1][0] th entry: 4

enter [1][1] th entry: 2

enter [2][0] th entry: 4

enter [2][1] th entry: 5

enter the second matrix:

enter [0][0] th entry: 2

enter [1][0] th entry: 3

enter the third matrix:

enter [0][0] th entry: 1

enter [0][1] th entry: 0

The product of the matrices:

2 3

4 2

4 5

and

2

3

and

1 0

is

13 0

14 0

23 0 - June 30, 2012 at 4:11 pm #3659AnonymousInactive
please help me …..i don’t understand that how to make this program by using array….

please tell me about the malloc function ….reply as soon as possible. - July 11, 2012 at 10:30 am #3660AnonymousInactive
Please visit the Site http://contest.collectiva.in/Contest/ContestTraining.aspx To learn Fundamentals of C Programming online video tutorials in Tamil. It is very useful for the Beginners.

- AuthorPosts

- The forum ‘C Programming’ is closed to new topics and replies.