 Hello friends, I am Sanjay Botta. I welcome you all to Sanjay Kappan Tech School. In this video, I am going to tell you how to write algorithms for matrix addition and separation. So first I am going to write algorithms for matrix addition. Then I will tell you how easily you can convert that algorithm for matrix addition. So if you want to add two matrix and you want to write there algorithm, so we need these parameters. So name of algorithm is matrix addition. First matrix, first matrix, then second matrix. So these two matrix will be added and we are going to write C matrix, R1 and C1. So this is row and column for first matrix and this is row and column for second matrix. So before starting a tradition, we just need to check the row and column values so that we can decide whether they are equal or not. So if row and column for row and matrix are equal, then only we can perform matrix addition otherwise. So now we need to start this. So step number one, step number one has begun. Step number two, so here we can write a condition. So if R1 not equal to R2 or C1 not equal to C2. So if any one of the condition is true, like row of first matrix is not equal to row of second matrix or column of first matrix is not equal to column of second matrix. So in both the cases, we cannot perform matrix addition. So here you can write print addition not possible. So if this condition is true, then this matrix will be printed and your page will be connected here. And you can also write any other message that you want to distribute. Now step number three, so if this condition is false, then we can perform matrix addition. So for that purpose, we need to implement a sort of writing in P for I equals to R1. So here we need to repeat the rule for rows and columns. So you can use R1 or you can use R2 because if this condition is false, it means R1 is equal to R2 and C1 is equal to C2. So you can use R1 or R2 in case of this rule. Now you need to apply one more rule. So repeat for J equals to 1 to C1. So here in case of second rule, you can use C2 as well. Now inside this rule, you can write C of IJ equals to A of IJ plus B of IJ. So this way IJ indexes of A matrix will be added to IJ index of B matrix as a third matrix of C. Then you can write AND of U. So this is what this do. Then again you can write AND of U. So this is what this do. After completion of both the loops, you can write AND. So this way all the indexes of A and B matrix will be added to the result. So by implementing a function for this algorithm, the help of C or any other. So in that case, the result will be R1 and C matrix. So either you can print that matrix or you can use that matrix for any other. So this way I will understand how we will write algorithm for adding new matrix. Also we check the condition like for both the matrix going on, should be equal so that we can perform the addition operation. Now if you want to apply subtraction operation. So we just need to remove this plus 9 and minus 9. And whenever we have mentioned addition, you can replace that X with subtraction. And the rest of the things will be same because in case of subtraction, we just need to subtract two numbers like we added two numbers. So this way I will understand how we can write algorithms for matrix addition as well as for matrix subtraction. So I hope you understood whatever you explained in this video. If you want to watch more algorithm related videos, so you can go to the description of this video. And then you will find links of our playlist so that you can understand data structure. Thank you for watching this video.