Linear search program in c is a simple type of searching where we find the element from the set of an element from beginning to end.

Linear search

Linear search is a simple type of searching where we find the element from the set of an element from beginning to end.
What is Linear Search? : The linear search is a sequential searching for finding value in a list.
Linear search process: In this, we (check) find the element from starting element and continues to check until the finding element to be found within a list and this process done till the last and if there is no such element then there is no element found in a list.

Page Contents

## Linear search algorithm

1. Define an array of an element. a[]= {1,4 2, 3 7}
2. Take input from a user which want to search. find
3. Traverse array
For i =0 to end
If a[i] == find
Print found
Break
Else
Continue
4. If array reached the end

## Linear search program in C

```#include <stdio.h>

int main()
{
int array, search, c, n;

printf("Enter the number of elements in array\n");
scanf("%d", &n);

printf("Enter %d integer(s)\n", n);

for (c = 0; c < n; c++)
scanf("%d", &array[c]);

printf("Enter a number to search\n");
scanf("%d", &search);

for (c = 0; c < n; c++)
{
if (array[c] == search) /* If required element is found */
{
printf("%d is present at location %d.\n", search, c+1);
break;
}
}
if (c == n)
printf("%d isn't present in the array.\n", search);

return 0;
}```

Output: 