Page 1 of 1

Linear Search

Unread postPosted: Thu May 22, 2008 6:27 pm
by rajeevmahura
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5],i,item,d;
clrscr();
printf("Enter Any Value in Array:-");
for(i=1;i<=5;i++)
{
scanf("%d",&a[i]);
}
printf("Enter The Searching Item:-");
scanf("%d",&item);
a[i+1]=item;
for(i=1;i<=5;i++)
{
if(a[i]==item)
{
printf("sucessful at %d",i);
d=1;
}
}
if(d!=1)
{
printf("unsucessful");
}
getch();
}
--------------------------------------------------
Input:- Enter Any Value In Array:- 6
2
3
4
5
8
7

Output:- Sucessful At