 Hello and welcome to the video lecture on accessing the array elements in a 2D array. At the end of this video lecture, students will be able to demonstrate how to access array elements in a 2D array. The following topics will be discussed in this video lecture, that is, reading the array elements and displaying the array elements. Now we will be discussing about how to read input elements into a 2D array. The for loop causes the process of asking for and receiving student's marks from the user to be repeated four times. It means marks of 0, 0, marks of 0, 1, marks of 1, 0, marks of 1, 1. The first iteration through the loop i and j have a value 0. So the scanf function will cause the value type to be stored in the array element marks of 0, 0, the first element of the array. The process will be repeated until i and j both become equal to 1, as there is no array element like marks of 2, 2. In scanf function, we have used the address of operator on the element marks of i, j of the array. We have used it earlier on the other variables. In so doing, we are passing the address of this particular array elements to the scanf function rather than its value. In this, whatever you see on the screen that is 2686708, 268671, 22686716, 2686720 are the address locations of the different array elements of the 2D array. Displaying the array elements. Now moving through the display of array elements, the for loop is the same. Now the body of the loop causes each marks to be displayed until i and j both become equal to 1. It means if I put an input value like 41, 63, 45 and 67 into marks of 0, 0, marks of 0, 1, marks of 1, 0 and marks of 1, 1, this will be displayed using the printf. So the final value will be 41, 63, 45, 67 with a space inside as I have used the slash t symbol. So 2686708, 268671, 2686716, 2686720 these are the address locations of the array elements. Now we will be discussing how to write a program for displaying the largest element in a 2D array which is of size 3, 3. Now I will be discussing how to write a program for displaying the largest element in a 2D array using code block software. So I will be declaring it as int at 3, 3, i, g. Now for this I have to get the input elements for all the array elements that is 3 x 3. So for i equal to 0, i is less than 3, 0 i is less than 3, i plus plus bracket, then for j equal to 0, j is less than 3, j plus plus bracket, printf slash and enter the elements of the array. Slash n ending with a semicolon scanf percentage g, scanf percentage g comma and aar of i, j bracket semicolon then. Now I am using a printf statement to find the procedure. Printf largest is, I will use the slash n symbol, then again for i equal to 0, i is less than 3, i plus plus bracket, j equal to 0, j is less than 3, j plus plus bracket, the largest element. If aar of 0, 0 is less than aar of i, j, then aar of 0, 0 is equal to aar of i ending with a semicolon, bracket, bracket. So I will print the largest element printf, the largest percentage g comma aar of 0 ending with a semicolon. Now I will go for build, I will go for compile, I will go for run. So it's asking me to enter the elements of the array, 1, 2, 3, 4, 5, 6, 7, 8, 9. So the largest element is 9. Now we will see how is it working actually, how is the program working, how is it displaying the largest element is 9. So this is the table created, i, j, aar of 0, 0, aar of i, j, aar of 0, 0 less than aar of i, j and largest element is something. So in your first row, first column that is 0 through 0 column element has a value equal to 1. So that is comparing again i and j will be 0, 0. So 1 is less than 1, it's a false value. So it will display the largest element as 1. Now again after this, j will be incremented to 1 and i will be near 0, it means first row, second column. So the aar of 0, 0 last largest element was 1, then aar of i, j is 2. So 1 is less than 2, yes it's true. So that's why the largest element is 2. Now again j plus plus, so the value of this, whatever the j plus plus 2, it means first row, third column element. The last largest value was 2 and the next is now 3. So 2 is less than 3, it's a true, then the largest element is 3. Now again this, after j plus plus, so it will be 2 plus plus is 3. So 3 again will be in a false condition. So it will come out of the loop and it will go for i plus plus, that is i equal to 1. Then j will be 0, it means second row, first column element. So the last largest element was 3, which was stored in aar of 0, 0. Now aar of 1, 0 is nothing but 4. So 3 is less than 4, it's a true condition, so 4. Now again the j plus plus, 0 plus plus is 1, it means first row, sorry it means second row, second column element, that is 5. Last largest element was 4, 4 is less than 5, yes it is true, so 5 will be displayed. Now again j will be uncommitted again, so it will be 2, so it means second row, third column element. It will have value called 6, last aar of 0, 0 was having a value called 5. So 5 is less than 6, yes it is a true, so it will display me the 6 value. Now j plus plus again it is a 3, so it comes, the condition is j is equal to 0, j is less than 3. So 3 doesn't fall, it is a false condition, so it will go for the next row. That is i will be incremented to 2 and it will start with j equal to 0, it means third row, first column element. Third row, first column element will have a value equal to 7. The last largest, last aar of 0, 0 value was 6, so 6 is less than 7, yes it is a true, so the largest element is 7. Now again j will be incremented to 1, it means third row, second column element. So it has a value called 8 and last aar of 0 was 7, 7 is less than 8, yes it is true, so the largest element is 8. Now again go for the other condition, next this one will be incremented to 2, it means third row, third column element. So it has a value called 9 and last aar of 0, 0 was 8, 8 is less than 9, yes it is a true, so the largest element is 9. This is how your program works for finding the largest element in the array. Now pause this video for a few seconds and try to write answer to the following question. What is the output of the following piece of code? Aint main, int aar, 1, 5 equal to initialized 1, 2, 3, 4, 5. Now printf slash n, %d aar of 0, 3, aar of 0, 4, written 0. Ok, ending with the prices that is curly brackets. So with respect to this when I say aar 1, 5 it means it will have aar 1, 5 is nothing but it is i is equal to starting index value is 0. Ok, array size minus 1 and here 5 minus 1, 4. So it will be 0, 0, 0, 0, 1, 0, 2, 0, 3, 0, 4. So when I execute it, it will be 0, 3 value will be having a value called 4 and the 0, 4 will be having a value called 5. So these are the output, this is the output of the following. So it will be 4 and 5 will be the output for your following piece of code. These are the following reference. Thank you.