# Matrix Calculator

Matrix calculator can be used to do mathematical operations on matrix problems such as multiplication, addition and similar maths. This program can be build in any language (C, C++, Java) of your choice.

Before starting to work on this program, this is very important for you to know, how to multiply matrix in mathematics. Without knowing its concept, you can't code this program. Though this calculator looks difficult to code but if you divide it into smaller parts, things will become much more easier.

In this post, I will try to explain algorithm of this program, so you can build it by yourself without any limitation of computer language.

1) In a first step, we need to ask the user to enter rows and cols for First Matrix, lets give it a name ONE, this can be done using cout in C++ and System.out.print in Java

2) In second step, we will take the input from the user and save it into two variables, first is for row and second is for col. Lets give them name x and y

3) In third step, we will ask the user to enter the elements of matrix. We will need two for loops and two dimensional arrays to store the values. For example, the first value will go to ONE[i][j] where both i and j are 0, but the second value will be stored when i is 0 but j will be one and this can be achived using for loop only.

4) Similarly as step 3, we will ask the user to input the values for Matrix TWO and we will store these values on TWO (second) multidimensional array

5) Than we will againneed the for loops, but this time three , first for loop will start from 0 and will have maximum value equals to number of rows. Second for loop will be inside the first loop and will also start from 0 but will have maximum value equals to number of columns of second matrix. In third for loop, it will start from zero having maximum value of number of rows of second matrix. Inside third and final loop we will store the multiplication values in third multidimensional array. For example please have a look at iteration of third for loop

THIRD_ARRAY = THIRD_ARRAY  + FIRST_ARRAY * SECOND_ARRAY

THIRD_ARRAY = THIRD_ARRAY  + FIRST_ARRAY * SECOND_ARRAY

THIRD_ARRAY = THIRD_ARRAY  + FIRST_ARRAY * SECOND_ARRAY

6) In sixth and final step, you will display the result using two for loop and THIRD_ARRAY .

I undertand that you may find this program difficult in first sight, but if you check the program again with above algorithm, things will look much better to you. For example, this program is about four functions, getting values for both matrixex(2 functions) + multiple them(1 function) and diplay the result (1 function) so total 4. The code project Matrix Calculator

Sourceforge simple matrix calculator

Related :