 Hello friends. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So in this video, I'm going to implement linear search. So if you want to watch its algorithm, so you can go to description of this video and there you will find a link of playlist. So you can watch its algorithmic implementation. So right now I'm going to implement the code so that you can understand how the research works. So first of all, I'm going to do the header file. Now I'm going to define a method. So its name is L search that is linear search, then here it will be receiving an array. It's size and item that we are going to search. Now I'm going to declare one variable as I variable LLC and I'm initializing it with minus one. Now I'm going to implement a loop. So loop will be starting from zero. It will repeat till this condition is true that is I less than then I plus plus. Now inside this loop, I'm going to apply if condition. So I need to check A of I with item. So if you find equals to item, it means the number is available in the area. So I can assign value of I into LLC and I can apply break. And when this loop will be completing, so I'm going to return value of LLC. So if item is available in the array, so its location will be available into LLC variable. Otherwise LLC will be having minus one. Now after its linear search function definition, now I'm going to define main function. So inside main function, I am declaring an array item variable. First I'm going to print a message for user. So enter size of array. I'm going to read this size for user. So right now it is a static array. It's a static array dynamically using mallop function. So initially size of arrays 20, but through this print up scanner, I'm going to read the size like actually how many elements user want to store. So that will be available into and now I'm going to apply a loop. This loop will repeat and times and inside this loop, I'm going to write print up statements. So enter number and scan of %d and %a of i. So this way using this for all the numbers will be stored into this array. Now I'm going to read the number that we are going to search in the array. So enter the number to search. So again scan f and number will be stored into item. So now here I need to call that linear search function. So I'm going to declare one more variable that is LOC. And here I'm going to call that function. So the more function is L search passing array size and item that we are going to search and the return value will be stored into LOC. Now I need to check if LOC not equals to minus one. Right. So if LOC not equals to minus one, it means number is found. So we can write print f on that position. And I'm printing LOC plus one why plus one because in case of C programming index is starting from zero. So let's say your element is available on first position. So LOC will be containing zero. But we want to print the location as one. So LOC plus one should be printed. Right. Else I can write print f number is not found. So this way the code is completely implemented and ready to execute. So I'm going to save this code. So I'm saving it as in your search dot C. Now I'm going to compile and run. So it is throwing an error. So here and is not declared. So I'm declaring it. I is also not declared. So I'm declaring it as well. Yeah. Now it is executed. So I'm entering the size as five numbers. One, two, three, four, five. The number you want to search I'm entering four. So you can see found at fourth position. So it is working well. Again, I'm going to execute this code. And again, I'm entering one, two, three, four, five. And this time I'm going to search six. So you can see number is not found. So this way the code of linear search is working perfectly. So this is the complete code implementation with the help of integrated development environment that is in front of you. And if you want to understand the logic with the help of classroom teaching, so those playlist links are available in the description of this video. So both algorithm implementation and the implementation of this code and explanation in classroom teaching. So you can watch that and you can understand it well. So I hope you understood how this code is working. Thank you for watching this video.