 Hello and welcome to the video lecture on accessing the array elements. At the end of this video lecture, students will be able to demonstrate how to access array elements. The following topics will be discussed in this video lecture. Reading the array elements, displaying the array elements. Reading the input elements in an array. Now we will be discussing about how to read the input elements into an array. The for loop causes the process of asking for and receiving students marks from the user to be repeated 4 times. It means marks of 0, marks of 1, marks of 2 and marks of 3. The first iteration through the loop has a value 0. So the scanf function will cause the value type to be stored in the array element marks of 0, the first element of the array. The process will be repeated till i becomes 3. This is the last time through the loop which is a good thing because there is no element like marks of 4. In scanf function, we have used the address of operator and ampersand on the elements marks of i of the array. Just we have used it earlier on other variables, ampersand rate for example. In so doing, we are passing the address of this particular array elements to the scanf function rather than its value. So this whatever you are saying is address element, they are the address locations i.e. 2686728, 2686732, 2686736, 2686740, displaying the array elements. Now we will be discussing about how to display the array elements. For the given loop displayed on the screen, the for loop is the same but now the body of the loop causes each marks to be displayed until i equals 3. It means first the printer first like for i equal to 0, 0 is less than or equal to 3, so printer percentage d, so marks of 0 will be displayed that is 1 will be displayed, then marks of then afterwards i plus plus means it is nothing but 1. So marks of 1 will be displayed on the screen that is 3, then afterwards then i will be incremented from 1 to 2. So it will be marks of that is 2 that is 5 will be displayed. Now i is incremented to 2 plus plus that is 3, so marks of 3 will be displayed on the screen. Now we will be discussing how to write a program for displaying the largest element in an array through the code blocks software. Basically this will be the default program when we open the code block software that is int main printer fellow mode. So I want to find the largest element in an array. So basically I will declare an array as we have discussed in the last class how to declare an array int error of 5, it means there are 5 elements the array size is 5. So the starting value or the starting index will be 0 error of 0 then 0 1 2 3 4 then comma i to indicate the loop counter. I will be having value 0 1 2 3 4 for i equal to 0 i is less than 5. In the arrays it has been discussed with the that the starting will be from 0 that is so the last element or the last index will be array size minus 1 printf. I will be asking user to enter the different elements inputs enter the elements of the array. I will be using a slash n symbol here basically so it goes to the next line it is appropriate I will put a colon then slash n. Then afterwards end with the semicolon scanf %d comma and marks of i it means reading is taking place at this particular statement so I will get the inputs and marks of 0 and marks of 1 and marks of 2 and marks of 3 and marks of 4 i less than 5. So afterwards printf slash n process to find the largest element in the array slash n ending with the semicolon again as I want to check for all the elements for I am checking for i equal to 0 i is less than 5 i plus plus bracket if r of 0 is less than r of i then r of 0 will be equal to r of i so after this is done then I say printf slash n largest element equal to %d comma r of 0 so I have compiled it enter the elements of the arrays asking 1 2 3 4 5. So the largest element is nothing but equal to 5 and equal to %d comma r of 0 bracket semicolon I will go for build I will go for compile I will go for run so 1 2 3 4 5 largest element is 5 so what is happening in this program is for i equal to 0 means marks r of 0 I am given input as 1 so r of 0 is 1 r of i that is the next thing r of 0 is less than thing now i plus plus it means 1 r of 1 that is output is 2 r of 1 input is 2 so 1 is less than 2 is it true yes so r of 0 will be having a value as 2 whatever the i plus plus will be incremented to what your next location afterwards the same procedure will be repeated and finally I get a value as 5 so this is how we write a program to find the largest element in an array so whatever the largest element will be stored in the r of 0 now so this is the program written now pause this video for a few seconds and try to write answers to the following question what is the index number of the last element of an array with 29 29 elements a 29 b 28 c 0 programmer defined so what is the index number of the last element of an array with 29 elements it means the size of an array is 29 so basically when we had declared an array or whatever we had discussed with the last class or the this slide it said for i equal to 0 that is the starting reading of the array element starts from 0 location so it will be 29 elements is 29 minus 1 28 so the option will be the b this is the following reference thank you