C program to multiply two matrices without function
Code Explanation :
In this example, we are going to multiply two matices that are given by user without function.
In this program, user input matrix row and column and give matrix elements and then after we multiply these two matrices.
Here we have uses
for loop to read and multiply matrix.
This is not the better way to write code. This is simplified using function.
It is better to do this example using function because we use
for loop for many times. That code, We have not to be used in
We are going to represent this code into algorithm and flowchart.
STEP 1 : Start
STEP 2 : Declare array a, b, mul with r, c,
i, j and k
STEP 3 : Read r and c
STEP 4 : Repeat this step until i < r
STEP 4.1 : Repeat this step until j < c
STEP 4.1.1 : Read for a[i][j]
STEP 4.1.2 : j++
STEP 4.2 : i++
STEP 5 : Repeat this step until i < r
STEP 5.1 : Repeat this step until j < c
STEP 5.1.1 : Read for b[i][j]
STEP 5.1.2 : j++
STEP 5.2 : i++
STEP 6 : Repeat this step until i < r
STEP 6.1 : Repeat this step until j < c
STEP 6.1.1 : mul[i][j] = 0
STEP 6.1.2 : Repeat this step until k < c
STEP 126.96.36.199 : mul[i][j] += a[i][k] * b[k][j]
STEP 188.8.131.52 : k++
STEP 6.1.2 : j++
STEP 6.2 : i++
STEP 7 : Repeat this step until i < r
STEP 7.1 : Repeat this step until j < c
STEP 7.1.1 : Print b[i][j] with tab
STEP 7.1.2 : j++
STEP 7.2 : Print "n" for line break
STEP 7.3 : i++
STEP 8 : End
If you got any difficulty on understanding this example, leave comment. we will explain you with more explanation.
Our example mainly covers following topics in any programing
- Basic Programs
- Number Programs
- Array Programs
- Matrix Programs
- Pattern Programs
- String Programs
- Tree Programs
- Singly Linked List Programs
- Circular Linked List Programs
- Doubly Linked List Programs
Here we share programs on various topics such as array strings, series area & volume of geometric figures, mathematical calculation algorithms for sorting & searching and much more.Our goal is to provide you with the perfect solution to all the programming problems you may have encountered either during interviews or in class assignments. If you don’t find what you are looking for then please drop a line in the comment section of example page or you can request from account page so that we can get it added to the below collection of programs. Happy Learning!!
If you are confident with the above programs and are able to successfully understand and run them without any problems then it is time for you to take a step further and learn comprehensive programming principles using examples and flow diagrams. Here is the link: Programming tutorial lists .
If you find this example helpful, don't forget to share it with your friends. And stay updated with us by subscribing adzetech.
If you find any code error or grammetical error then you can suggest for example improvement on clicking below button.