 Hello friends, I am Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So in this video, I am going to explain how to implement linear search algorithm with the help of C language. So before starting, if you want to watch its algorithm implementation, I will go to the description of this video and you will find link of the playlist that has data structures and algorithm. So there you will find how we can write algorithm with linear search. So now let's begin with the C implementation of the algorithm. So different type is white function name is linear search. Then here I am passing an added, sorry I am expecting an array from the caller method, then int n that will be the size of array and int item that we need to search in the array. So these three parameters are required, array, its size and the item that we want to search, whether it is available in the array or not. Then I am declaring one variable i, one more variable loc and I have initialized it with minus one. Now I am writing an algorithm which is starting from 0, it will go to i less than n and then i less than n. Now inside this loop, I need to compare the item that we are going to search in the array. So that will be compared with AO5. So if AO5 is double equals to item, it means item is available in this array and on IAC index. So now if this condition is true, so I am going to assign value of i into analysis. So if item is available on a particular index of array, then only this will be assigned and after this we can write break even because if this condition is true, if this condition is true, it means item is found in the array on this index. So unnecessarily we don't want to iterate this loop forever. And if this condition is false every time whenever we are iterating the loop, so in that case this loop will complete all the rotations and loc value will be minus one. So after completion of this loop, now here we need to check the value of loc. If it is not equals to minus one, if value of loc is not equals to minus one, it means loc is having a value that is related to item or you can say that is that value on which the element is available. But that is an index and index starts from zero. So let's say your element is available on the zero condition. So for us that is first position. So now if you want to print that location, so how you can do that? So here you can print loc plus one and else you can print not found. So this way this method is implemented. So if location is not equals to minus one, it means it is having a particular index on which number is available. So you can do a plus one so that proper position can be displayed. So it will display found that let's say element is on zero thing that's going to print found that first position. So this way it will work. And if you want to return this value of LOC to main function, because this linear search function will be called through main, if you want to return that location to main function as well. So you can put return type as in here and maybe you can remove these statements and you can write return and in main function you can put this if I so that if you want to use that location anywhere in any other function, so that will be better to return the location of the found number. So you have both the scenarios if you want to display the print def statement here in this function that you can do this. And if you want to return the location to the main function that is calling this linear search function so that it also. So this way I have explained to how you can implement linear search algorithm with the help of a secret map. So this is a function that will be called by main function so that it will execute properly. And if you want to know how we can write algorithm for linear search, so go to the description of this video and search for data structures and algorithm playlist link and then you will find all the algorithms related features. So watch them and understand how to write algorithms and how to write their seed program. So I hope you understood whatever I explained in this video. So thank you for watching this video.