 Hello friends. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. In this video, I'm going to explain how to read 2D array, how to print elements of 2D array in matrix format on output screen and how you can calculate some of all the elements which are available in 2D array and to print that some on output screen. So I will be implementing this program in C language. So before starting explanation, just one update. If you go to detail or description of this video, you will find links of various playlists related to C programming. So you can follow them. Now I'm going to write the program server set. So first I'm going to tell you how you can read 2D array elements from unit. So starting with main function. First of all, you need to declare a 2D array. So here I'm declaring a 2D array whose dimension is 3, 4. So 3 is number of rows and 4 is number of columns. Then I'm declaring variable i, j and one more variable that is s who will be having calculated some. Now after this, I'm going to write a print test. So you can write this message, enter 3 by 4 matrix. Now to read 2D array, you require master loop. So first loop will repeat number of row time that is 3 and inside this loop, you need to apply one more loop. That will repeat according to column value. So that is 4 and inside this loop, you can write a scanf and address of a of i, j. Right. So this way with this master loop formation, you will be able to read all the elements of 2D array. So let's say I'm drawing this here. T rows and here we have 4 columns. Now I'm putting indexes. So if we see first row indexes will be 00, 01, 02 and 03, then 10, 11, 12, 13, 20, 21, 22 and 23. So this way we need to use these indexes so that we can store the values. So now I'm going to repeat this loop so that you can understand how values will be stored. So first I will be starting from 0, then control will be transferred to this loop. And if you are facing any problem to use these 3 statements without curly braces, so you can put them like this. So now it is more readable, but each statement is having only one statement under it. That's why I didn't use curly braces, but if you are facing any problem, you can use that. So i is starting from 0, then check the condition. It is true. Control will be transferred to this j loop. So when i is repeating one time, then j will repeat 4 times because it is starting from 0 to and going to 3. So initially j will be 0. So here you can see address of aij is written. So it will be like this. The first number will go to a00 position. So that is this position. So at this position, the anchor number will be stored. Then only j will be incremented to 1. So this time it will be a01. So next number that will be entered by user will be stored here. So this way j will be incremented again. So it will be a02 and then a03. So these 2 positions will be filled and 4 rotations of j are completed. Then i will be incremented. It will be incremented to 1 and j will again start from 0. So next time what will happen? Indexes will be this. 1 0, 1 1, 1 2, 1 3. So 1 0 is this, 1 1 is this, 1 2 and 1 3. So this way whole 2D area will be having values provided by the user. So i hope you understood how this loop is working. Now i am going to implement a second section that is printing. And inside the printing section i am also going to calculate the sum. So our requirement is we need to print the matrix in this format. So first time using print as, so i am writing this matrix. So it will be printed on the first page. Then again i am going to start nested loops. So here you can see first loop is repeating row times and second loop is repeating column times. Now here inside this loop first time performing addition operation. And after this i am going to print this value with % then backslash t. So this backslash t is for tab. So it will print some space between 2 digits. Then i am closing this loop. So this loop will be between 4 times. So it will add all the elements of first loop as well as it will print all the elements of first loop. Then after completion of this loop i am going to use one more print as which will change the cursor position to new line. So after completion of this j loop first row is printed. So now i want my cursor to be available at second row. So after completion of this loop you can use this printer backslash t. And then you can complete this loop. And after completion of this loop you can print calculated sum that is available in as variable. So you can print that. And then you can close your main function. So this way this part is for reading. This part is for printing 2D area on output screen as well as calculating sum. And this printer is printing calculated sum on output screen. So this printer is outside all loops because if we calculate a total sum of 2D area so it will be only one value. So after completion of all loop cycle we will be having that calculated sum. So we can print that with the help of this printer. So i already explained you the rotation. So now i can i hope you can understood this rotation as well because it will be having a 0 0 then 0 1 0 2 0 3 positions in these two places. So first row elements will be added with this and first row elements will be printed with this printer state. Then after completion of this loop i will be incremented. So i will be having value as 1 then for second row it will be again. So all four elements of second row will be added and along with them they will be printed. So this way i explained you how you can read 2D area from user, how you can print that in form of matrix on output screen and how you can print total calculated sum of that 2D area on output screen. So i hope you understood whatever i explained in this video. If you want to watch more programming related videos so you can open my channel go to playlist or you can go to detail or description of this video. Here you will be having links of various playlist attachment. So if you want to follow programming related videos so watch my videos those are available on YouTube. So i hope you understood whatever i explained thank you for watching this video.