Pages

Subscribe:

Linear Search

Linear search is not the most efficient way to search for an item in a collection of items . If the array elements are arranged in random order , it is the only reasonable way to search . Linear search is very simple to implement .The simplest of all the searching techniques is Linear or Sequential search.

Program :

#include<stdio.h>
#include<conio.h>
/* Global variables */
int flag;
/* Function Declarations */

void liner_search(int []);

void main()
{
char ch;
int i, arr[10];
do{

    clrscr();
    for(i=0;i<10;i++)
    {
        printf("\n\t Enter No : ");
        scanf("%d",&arr[i]);
    }
    liner_search(arr);
    printf("\n\tContinue(y/n):");
    ch=getch();
}while(ch=='y'||ch=='Y');
}
void liner_search(int arr[10])
{
int i,s;
flag=0;
printf("\n\t Searching No: ");
scanf("%d",&s);
    for(i=0;i<10;i++)
    {
     if(arr[i]==s);
     flag=1;

    }

if(flag==1)
        printf("\n\t Search sucessful ");
else
    printf("\n\t Unscessful ");
}

Output :



If you have any Further Information and Quires about this Article don't hesitate to comment in comment box below.
                                                           AND

 If you like this article , like our Facebook like page and click  +1 to support 123techguide
comments powered by Disqus
 

Listed In

Bloggers - Meet Millions of Bloggers http://Link-exchange.comxa.com
Blog Search: The Source for Blogs Internet Blogs

Disclaimer

The contents in this blog are taken from various sources available over the internet, therefore we do not gurantee of it's accuracy, if you find any of the content in the blog is infringing it's copyright, please do email us on '123techguide@gmail.com' and we will make sure to remove the same from the blog at the earliest.