matrix opreation in c

Home Forums C Programming matrix opreation in c

Viewing 2 reply threads
  • Author
    Posts
    • #2254
      Anonymous
      Inactive

      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 matrix

      e) 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

    • #3659
      Anonymous
      Inactive

      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.

    • #3660
      Anonymous
      Inactive

      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.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.