C++ Matrix Multiplication Program

Here you will get C++ matrix multiplication program.

What we are doing in this program.

Read number of rows and columns for two matrix.

Then check if matrix multiplication is possible or not.

If not possible then show a message to user otherwise multiply them. Finally display the result.

C++ Matrix Multiplication Program

 

Output

C++ Matrix Multiplication Program

18 thoughts on “C++ Matrix Multiplication Program

  1. Aditya's Art Work

    This somehow does not work/compile for me.
    It throws out the follwing error:

    No main found…simply generating .o files…
    In file included from
    /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/backward/iostream.h:31,
    from mat.cpp:1:
    mat.cpp:2:18: conio.h: No such file or directory
    mat.cpp:5: error: main' must return int'
    mat.cpp:5: error: return type for main' changed to int'
    mat.cpp: In function int main(...)':
    mat.cpp:6: error:
    clrscr' was not declared in this scope
    mat.cpp:40: error: `getch' was not declared in this scope
    mat.cpp:6: warning: unused variable 'clrscr'
    mat.cpp:40: warning: unused variable 'getch'

    Reply
    1. Neeraj Mishra

      By taking a look on the errors i concluded that you are using gcc on linux os. The above code is written in turbo c++ so it will not work in gcc.

      Reply
    1. Neeraj Mishra

      Actually getch() is a function used to read character value without displaying it on the screen. When it is added at the end of the program, compiler waits and stops the screen for reading any character, as we press any key the program ends. I hope this will make you understand the use of getch().

      Reply
    2. kishan vaishnav

      I think u r new to c getch () is for inputting character value bt to keep output on the screen we hv to use getch other wise output will be terminate in just mili seccends

      Reply
    1. Tech From India

      so that there are spaces in between the matrices and two numbers can be differentiated.
      for ex:- 80 90 39 without space can be 809039. it will be difficult for us to know the numbers without spaces.

      Reply
  2. Sreekant

    Your Website really helps me in passing my exams 😛 since I need to do ctrl + F on my notebook (real notebook) Hehhee.

    Reply
    1. Admin Post author

      Hey Shreekant, I am so happy to know that my website is helping you, keep visiting and recommend it to others 🙂

      Reply
  3. Muhammad Umair

    man that program isn’t helpful for me
    may be it’s a wrong code

    Reply
  4. Ahmado

    Hey the code gives the wrong answer when i input 1->9 for matrix 1 and 9->1 for matrix 2

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *