You are on page 1of 1

/* Name- Vijay Patil Div- E Roll no.- 21 Assingnment 10 Aim- Linear Search. */ #include<stdio.h> #include<conio.

h> int main() { int a[10],n,i,key,flag=0; clrscr(); printf("\nEnter no of elements"); scanf("\n%d",&n); printf("\nEnter elements"); for(i=0;i<n;i++) { scanf("\n%d",&a[i]); } printf("\nEnter the no whose position is to be found out"); scanf("\n%d",&key); for(i=0;i<n;i++) { if(a[i]==key) { printf("\nThe position is %d",i+1); flag=1; break; } } if(flag==0) { printf("\nNo is not in list"); } getch(); return 0; } /* Output vit@vit-HP-Compaq-4000-Pro-SFF-PC:~$ cc linearsearch.c -o linearsearch vit@vit-HP-Compaq-4000-Pro-SFF-PC:~$ ./linearsearch Enter no of elements4 Enter elements12 14 56 78 Enter the no whose position is to be found out56 The position is 3 vit@vit-HP-Compaq-4000-Pro-SFF-PC:~$ */

You might also like