A program for linear search to search the user choise from the list

Write a program for linear search to search the user choice from the list.

#include<stdio.h>
#include<conio.h>
int main()
{
int a[10],i,j,c,search;
printf("enter how many number to input:");
scanf("%d",&c);
for(i=0;i<c;i++)
{
printf("enter a[%d] value:",i+1);
scanf("%d",&a[i]);
}
printf("enter number to search:");
scanf("%d",&search);
for(i=0;i<c;i++)
{
if(a[i]==search)
printf("%d is found on %d\n",search,i+1);
}
}

Output:




        For More Updates:
      Follow my page from right sidebar
Thank you!!

1 comment:

Powered by Blogger.