 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 pass a 1D array into a function in C language. So I will be implementing this problem so that we can identify some of array by passing that into a function. So before start, I just want to give you one information. If you go to description of this video, you will find links of various areas related to C language. So you can follow or see videos on those pages as well. So now after this information, I'm going to explain this scenario. So here we will be using two features of C. First is 1D array and second one is function. So here in this program, you will see I will be implementing two functions. One will be main and another will be function that will receive input from main and it will process array and it will return the result into main function again. So after watching this video, you will understand how we can pass a 1D array into a function and how we can process that. So as I hope you know about functions, so function have three parts. First is declaration, second is calling and third one is its definition. So first I'm going to declare the function. So if you want to declare any function, you need to write the statement before main. So this way I wrote this statement in sum that inside parameters I mentioned in square bracket. So this is declaration. This is declaration of function, right? After this, I'm writing main. So here this thing is written type. This is name of the function and this is indicating that I'm going to pass an argument that is an array, right? And if you don't know about functions, so after completion of this video, you will see a link of a playlist related to function safety. So you can go through all the videos that are available in that playlist so you will understand how basically function works. Then you can relate this program, which is explained in this video after watching those. So you will understand how we can pass these arguments into function. So if you want to pass an array, you need to use data type and square bracket, then here let's say I am declaring an array and also I am finishing it with these values. So we have two options. Either we can provide values ourselves or we can read values for that array from user, right? So if you want to take values from user, then you can apply a follow along with scanner so all the numbers will be entered by the user. So for example purpose, I am myself initializing these values. I'm not going to be values from the user. Now I'm declaring one more variable that is as which will store the sum. Now I'm going to call this function and passing this array, right? And using printf, I can display sum equals to percent b and s and this is closing off me. So here you can see this statement is calling a function. So as I told you function have three parts, declaration calling and definition. So this one was the declaration and here we have calling. So in calling, you need to pass the array as an argument. This is name of the function and s will be having the return to value that is the output of a particular function that will be stored inside this s. Now after defining these two parts, now I need to define the definition of function. So name of function is thumb. So here I'm going to define it. So here you can see this is the main function which is starting from here and ending here. Then we have another function whose name is thumb. This is a return type. It is receiving an argument. So when we call this function control will be transferred to here. And this A will pass into this A. So A will throw all the values which are available in this array to this array, right? Now here I'm going to declare two more variables I to rotate the loop and I s to hold the sum. Now I'm iterating the loop then s equals to s plus a of i. After completion of this loop, I'm going to return value of s. So return statement will throw this value back to this S. So calling will jump here. A value will be passed to this array. Calculation will be done. Final result will be available into s variable and through this keyword that is written, the result will be again stored into this s variable and then this print cap will work. So when you will be executing this program, the control from calling will transfer to definition when definition will work, it will return the value to this variable and then this print cap will be executed. So this body is the third part which is known as definition of the function. So this way, friends, you can pass array into function, you can process it and then you can return the result to main function back. If you want to pass more than one array, then you can modify it like this. So you can put h square bracket comma h square bracket, it means you are going to pass two arrays. Here you can write a comma b. So you need to declare the array as well here. And then you can write in b square. So this way you can pass any number of arrays that you want to into a function and accordingly you can modify your own. So I hope with this simple example you understood how we can pass one array into function for performing any calculation and I again want to tell you if you want to go through how function works, how we can define function, how declare call and definition work. So at the end of period, I am going to attach a playlist related to functions in p. So there will be around 15 to 16 programs related to function itself. You can watch them and then you will, I'm sure you will be understanding this program. So I hope you understood if you know about function. So I hope you understood whatever I explained in this video. If you don't, then watch functions first and then come back to this video. Charlie, you will understand this. So if you want to watch more more programming related videos, go to description and see all the links of playlist related to C language. And thank you for watching this video.