Feed Headline Animator

Example of linear or sequential search

main()
{
inta[10],sr,I,loc=0, f=0;
for(i=0, i<=10,i++)
{
printf(“Enter the number\n”);
scabf(“%d”,&a[i]);
}
printf(Enter the number to search\n”);
scanf(“%d”,&sr);
i=0;
while(i<10&&f==0)
{
if(sr==a[i])
{
f=1;
loc=i+1;
}
else
i++;
}
if(f==1)
printf(“Element is found at location=%d\n”,loc);
else
printf(Element is not found\n”);
getch();
}
}


Posted by: Wasim Javed

No comments:

Post a Comment