 Hello, friends. I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to explain how you can calculate sum of two metrics and subtraction of two metrics, right? So I will be implementing the solution in C language. And before starting, just one information I want to share. If you go to detail or description of this video, you can find links of various players related to C programming video. So you can follow that. Now I'm going to write the solution. So first of all, inside main function, I am declaring three 2D arrays. So A33, then B3 by 3, and C3 by 3. So I'm going to read A and B 2D arrays from user and I am going to add their corresponding indexes and storing their sum into C matrix or 2D. And I'm going to use two variables I and J for maintaining the loops. Now, printf will print the message enter first 3 by 3 matrix. So this message will be printed. Then to read values, I'm implementing a master loop. So these two loops will be repeating this scanner statement. And all the elements will be stored inside A2D array to this state and add different indexes. Now, similar to this, I'm going to read second 2D array and then I will apply the addition. So again, I'm writing printf enter second 3 by 3 matrix. Then again, two for loops. So I will be for rows. I will be for rows and J will be for columns. So J is for columns and then scanf. So this scanf statement will be reading values from user and those values will be stored inside B matrix, B2D array. Now, after reading these two 2D arrays, I can apply the logic for adding those values. So after this, I'm going to write that. So I'm combining two logics. I will be adding A and B and storing their sum into C and immediately I'm going to print the values of C matrix on output. So that corresponding indexes sum will be displayed on output screen as well. So here, first time writing a printf sum of matrix. So this message will be displayed on output screen. Now I'm going to apply first loop for rows, second loop for columns and inside the second loop, I need to add those indexes. So here I'm writing Cij, Cij equals to Aij plus Bij. So this way, A array, IJ indexes value will be added to B array, IJ index value and that will be stored on Cij array index position. And just after this addition, I'm going to display it on output screen and to provide some space between our two values, I'm putting backslash t and then C of IJ. So C of IJ will be displayed on output screen and I'm using this for loop, which is for rows, sorry, which is for columns. So once it is completed, I need to change the row that first row will be printed. So I need to shift the cursor to the new line. So after completion of this, I'm going to write printf and backslash and then this I loop will be completed. And after this, you can close the main function, right? So let's say now I implement the matrix. So this is A, this is B and these are values, both are having same values. These are the indexes, 012, 012, all are same for rows and columns. And this is C matrix, which is blank and these are the indexes, right? Now what we need to do, we need to add these 1, 1, we need to put 10 here, then 2, 2, 4, 3, 3, 6. So this way we need to add. So loop will start from here, I will be 0. Then control will shift to this J loop. So J will repeat three times. This J loop will repeat three times. So first time you can see J is 0. So what will be our combination? A00 will be added to B00. So A00 is 1, B00 is 1, both are added and stored at C00 position. So 1 plus 1, 2 will be stored here and immediately it will be printed on output screen with this print. Then J will be increased only. So J will become 1. So next time A01 and B01. So A01 and B01, 2, 2. So 2 plus 2 will be stored at this position, which is Cij, C01. And immediately it will be printed. Then again J will be incremented. So J is now 2. So this time 0, 2, 0, 2. So 0, 2, 0, 2 indexes are having 3, 3. So 3, 3 will be added and maybe it will be stored at 0, 2 indexes of C matrix. So it will be having 6. So this way I hope you understood how we can add values of 2 matrix with the help of master rules. Now if you want to apply a subtraction, so you just need to replace this plus time with minus. And the values will be subtracted and the subtracted result will be printed on output screen. Sorry, so once you implemented some of 2 matrix, then you can easily implement subtraction of 2 matrix as well. So I hope with this explanation in this video you understood how we can add corresponding values of 2 2D arrays and how we can store the result into third 2D array and how we can store that into output screen. So implement this in your system so that you can understood how it is working. And if you want to watch more programming related videos, you can open my channel, go to playlist and you can watch various variety of videos. So thank you for watching this video.