/*Linear Search*/ #include<stdio.h> #include<conio.h> void main() { int key,i,a[10],n,flag=0; clrscr(); printf("Enter the number of elements"); scanf("%d",&n); printf("Enter array elements:"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("Enter Search Element"); scanf("%d",&key); for(i=0;i<n;i++) { if(a[i]==key) { printf("Search Element Is Found at Location %d",i+1); flag=1; return; } } if(flag==0) printf("Search Element is not found"); getch(); }
C Program For Linear Search
January 02, 2015
By:
Bhanu Namikaze
Bhanu Namikaze
Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.
No comments:
Post a Comment