Thursday, 9 August 2012

implementation of linearsearch using arrays in c language

#include<stdio.h>
#include<conio.h>
int main()
{
    int key,i,a[]={11,3,56,78,93,45,26,28,6,71};
    printf("enter a values to search:");
    scanf("%d",&key);
    for(i=0;i<=9;i++)
    {
                     if(a[i]==key)
                     break;
    }
    if(i==10)
    printf("search element is not found");
    else
    printf("search element is found at %d location",i+1);
    getch();
    return 0;
}

No comments:

Post a Comment