/***************************************************
* Program to search for an item using Linear Search
****************************************************/
#include<stdio.h> // include stdio.h
#define SIZE 10
int main()
{
int arr[SIZE] = {100, 91, 22, 52, 71, 9, 11, 24, 2, 80}, is_found = 0;
int target; // number to be searched
printf("Enter element to search: \n");
scanf("%d", &target);
// search for the target sequentially
for(int i = 0; i < SIZE; i++)
{
if(target == arr[i])
{
// if target is found stop the search and break out
is_found = 1;
break;
}
}
if(is_found)
{
printf("Item %d found.", target);
}
else
{
printf("Item %d not found.", target);
}
// signal to operating system everything works fine
return 0;
}