C Program to Implement Linear Search
Get Certified in C Programming and Take Your Skills to the Next Level
Program 1
//Program for Liner Search from Array
#include<stdio.h>
#include<conio.h>
int main()
{
int ar[500],n,i,max,s,f=0;
xyz:printf("\nEnter limit for array");
scanf("%d",&n);
if(n>500)
{
printf("\nInvalid limit pls enter between 1 to 500");
goto xyz;
}
printf("\nEnter elements in array");
for (i = 0; i <n ; i++)
scanf("%d",&ar[i]);
printf("Enter element for search");
scanf("%d",&s);
for(i=0;i<n;i++)
{
if(ar[i]==s)
{
f=1;
break;
}
}
if(f==1)
printf("Searching success........");
else
printf("Searching not success........");
return 0;
}
We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

