 Hello friends. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to demonstrate you the complete code implementation or matrix multiplication with the help of C language. So you might have watched my video based on matrix multiplication algorithm if you didn't watch. So you can go to description of this video. There you will find three playlist links. First is data structures and algorithm. So there you will find how we can write matrix multiplication algorithm. So this link is also available in the description of this video. Then if you want to understand how the logic is working in form of classroom teaching, so that is second playlist. And this is the third playlist, DSA code implementation where I'm putting all the videos where I'm actually implementing code with the help of IDE so that you can understand the implementation. So there will be three playlist, one related to algorithm explanation in classroom. Second is related to C code implementation explanation in classroom. And third is C code implementation with the help of IDE. So for this purpose, I'm using DAB C++ as of now. Now I'm going to start my explanation or you can say implementation. So return type is void name of method is multiplication. It will be receiving three parameters. So first parameter is in A33, second parameter in D33 and third parameter is in C33. So right now I'm using same row and column but there may be chances like your rows and columns dimensions are different. So for that, you need to apply some condition like our first matrix column will be equal to our second matrix row that we can apply the multiplication process. So let's say for example, if your first matrix sizes 23 and second matrix sizes 32, then here you can see its column size and its row size is same so multiplication can be done. And the resultant matrix size will be 2 by 2. So if you have an even size then you need to apply if condition as well then only your matrix multiplication will work properly. So right now I'm using same dimension so that I can show you how we can implement the functions only. Later on you can modify the logic as well by watching my classroom video. So here I'm going to implement three variables ijk, then first loop will repeat three times, then inside i I am implementing one more loop, j that will be for column multiplication. And here I'm going to initialize C matrix ij position with zero because I'm going to use this index position for adding the values. So I am going to remove the garbage value and filling it with the help of zero. Then K is initialized with zero condition is K less than 3 and then K plus plus. Now inside this K loop I'm going to apply the logic for matrix multiplication. So here Cij equals to Cij plus Aik multiplied by Bkj. Now how this logic is working so that is totally explained in my lecture video that is classroom teaching. So there with the help of board and market I draw a drawn matrix like three matrix ABC and I showed how this multiplication will be working. So I cannot draw those pictures here. So that's why I created for that video. So you can find the link in the playlist. Sorry, you can find the link of playlist in the description so that you can watch that as well. So here I already said you I will be only explaining you like how you can implement matrix multiplication method separately and how to get all that into the function. So now to execute this multiplication method we need to define a function. So inside main function again we need to create the matrix. So first is A second is B and third is C then two variables IJ then print F and first matrix and follow. So I'm just popping these two loops. Now inside this loop I'm going to write scanf and values will be stored inside a matrix with the help of this scanf statement. Now I'm going to close this J then I'm going to close I do so this way first matrix values will be entered. Now I'm popping this. So now I'm changing this to enter second matrix and here I'm going to change this to B IJ. So this way this code will read values for first matrix. This code will read values for second matrix and now I'm going to call the multiplication method. So method name is multiplication and I'm passing K, B and C as input for that method. So here you can see A and B will be multiplied and the result will be stored in C matrix but we are not returning C matrix. So remember one thing whenever you change a particular 2D array or 1D array to any function so the changes will be reflected automatically because from here you passed C as an argument it is received here in this variable and now we are trying to modify this variable so it will automatically modify the value of actual panel. So in short you can remember like if we are passing A, B, C as parameter from here so whatever we change into A, B, C will be reflected to these parameters automatically. So now I can print the values which are available in to C after completion of this call it statement. So this is function call and above main function definition is written. So after completion of that definition we can print output as multiplication. So multiplication is this message will be printed now we need to print the values of C matrix. So here I'm going to use printf in place of scanf, backslash t for tap position and after completion of this inner loop I'm using backslash n so that each row will be printed into new line. So this way the program is completely implemented. So this is the complete program implementation that will perform multiplication for 2 matrix. So now I'm going to execute this. So I'm picking this option compile and run so that we can check for any error. So it is showing the error. Okay, so we need to use stdo.h header file so that our printf scanf works properly. So that was the mistake. That's why we first compile and then execute the program. So come in at the time of compilation 2 things happens first compiler checks whether your code is error free. If it is error free, then it will be converted into binary code and then execution happens. So now I'm going to enter post matrix values. So I'm entering all ones in second matrix also I'm entering all ones. And if you calculate this mathematically so the result will be 3 at all places on C matrix and that is happening. So this way you can see matrix multiplication is working properly. So we printed values of C which is printing correctly. So this way you can implement separate method for matrix multiplication and you can call that method into main function. So again, if you want to watch its algorithmic implementation or you want to understand how this matrix multiplication logic is working. So again, you can go to the description of this video and you will find these three DSA related playlist links. So you can open anyone that you want to follow and I hope you will learn a lot of things by following the playlist. So thank you for watching this video. .