The linear search is probably the oldest search algorithm, it goes through each and every element of the unsorted array and look for the key, you are searching for. C … Find Maximum and Minimum Using Pointers. If you want to stick with using VLA for b, you can alter your linearsearch to return count only if b is NULL. The program implements two search algorithm – linear search and binary search. Then, you can create b as VLA, and pass it back to linearsearch again to be populated. Linear search is a very simple and basic search algorithm. Simple Binary Search Example - Array and Functions Enter 5 Elements for Searching : 1001 1020 3002 4001 5000 Enter Element to Search : 3002 Search Element : 3002 : Found : Position : 3. Problem Definition. (Linear Search Method). Let's apply a linear search algorithm and write a function to carry it out. In this blog on “Linear search in C”, we will implement a C Program that finds the position of an element in an array using a Linear Search Algorithm. int count = linearsearch(n, a, x, 0, 0); int b[count]; linearsearch(n, a, x, count, b); Then, your function could look like: Our function will take three arguments: the array to search, the number of elements in the array, and a value to search for.