 Hello friends, I am Sanjay Bhukta. I welcome you on Sanjay Bhukta Tech School. In this video, I am going to explain how you can pass an array into a function using pointer. So before starting explanation, if you go to description of this video, you will find links of various playlists related to scene language videos, so you can follow them. So now I am coming on to this topic. So first of all, I am going to declare a function. So let's say this is function declaration. So here name of function is done, its return time is integer and it will be receiving an argument as input that will be an array, but that array will be received into a pointer. So that's why here I have mentioned in asterisk. So whenever you pass an array into a function and you want to process it with a pointer. So remember, always you need to declare a pointer here. Now I am starting main function. Inside main function, I am declaring an array and initializing it with five values. So size of array is five and it is having five values as initial value. And one more variable that is S, which will be storing some. Now after this, I am just calling some function and passing this array as an argument into it. So this statement is function declaration and this statement is function calling. So here you can see I am passing an array as an argument and the result will be stored into this S variable when this sum function will be returning the calculated value. And after this, I can write print S sum equals to person D and variable S and then I can close the main function. So remember that in this program, I have initialized these values by myself. So if you want to read these values from user, so remove these values from here. And after this variable declaration, you can like enter scatter statements so that you can read values from user. Right. So after this main function definition now I am writing definition of some function and here I am writing this. So this array will be passed as an argument and that will be received into this P pointer. So here you need to remember one thing. So name of array provides its base address. So whenever you have name of any array, it means you can directly access its base address. So here we are passing name of array into P pointer. So P pointer will be having base address of the array. And through that base address, if we increase that one by one, so we will access all the elements of array those are stored inside the array. So now we are going to use that approach. So here I am going to declare two variables. One is I and second one is S. Now I'm going to iterate a loop. So this loop will be five times because size of array is five. If you want to repeat it n number of times, then you need to pass size of array as an argument answer. So that inside this definition, you will know how many times you need to iterate. Now inside this loop, I can write S equals to S plus S plus P and I can increase value of P that is a pointer. And after completion of this loop, I can simply return value of S. So this way this loop is implemented. So now I'm going to take an example. So suppose these are five coefficients, name of this array is A, these are indexes and these are values which are available inside this array and these are addresses. So I am taking example of 16 bit compiler. So in case of 16 bit compiler, size of int variable is always two bytes. So here you can see one zero one and one zero two. Two dots or two addresses or two bytes are reserved for this first block. Then one zero three and one zero four are reserved for this second block and so on. So total 10 bytes are allocated here. And here we are passing base address of A and it is received through P pointer. So if I drop P, so it will be having one zero one as a value. Now here S plus S equals P. So this S equals means value at address. So address is one zero one and the value which is available in this address is 11. So this 11 will be added into S. Then P will be implemented. So P is a pointer of integer type. So integer pointer always increases its address that is stored inside it by two bytes because we are talking about 16 bit compiler. So it will move to one zero three location by this P plus plus. Then I will be implemented for second quotation. Now we need to add S plus S plus P. So this time P is having one zero P as address. So value at this address because S plus P is available here. So value at one zero or P is trial. So trial will be added into S. So this way P will jump its location one by one and through S plus P we can access the element which is available on particular address. So if we talk about this function definition. So here you can see we have not used anywhere name of added. We just used addresses of the added through this pointer. So this way you can pass any quantity array into the function and that function will receive that array into a pointer and through that pointer you can process it. And after completion of this loop the result of S will be returned into this S variable and it will be displayed here. So this way I hope you understood or you understood whatever I explained related to passing array into function with the help of pointer. So after watching this video you have two options. You can pass this array into another array. So we can also use this notation. So this array will be passed into this array. But if you don't want to use any array and you want to process it with the help of pointer. So this is another notation. So after completion of this video you will find a link of playlist where you can see videos related to pointer. So there all pointer related videos are available so you can watch them too. And if you want to watch all related playlist of C language. So go to description of this video and you will find links of all available playlist on my channel on this description of this video. So I hope you understood whatever I explained in this video. Thank you for watching this video.