Example 62: Linear Search
Explore how to perform a linear search on an array of integers using C programming. This lesson helps you understand searching through arrays sequentially, applicable to both sorted and unsorted lists, and guides you in writing a function that returns the position of the searched element or indicates if it's not found.
We'll cover the following...
We'll cover the following...
Problem
Linear search is the simplest method of searching an element in an array. In this method, the element is sequentially searched in the array. This method can be applied to a sorted or unsorted list.
Write a function that performs a linear search on an array of 10 integers. It should either return the position of the first occurrence of an element if it is found or -1.
Demonstration
The array ...