Linear
Linear
#include<stdio.h> #include<conio.h> void nonreclinear(int a[],int ,int ); void main() { int a[20], n,key,i; int ch; clrscr(); printf("Enter the number of elements :"); scanf("%d",&n); for(i=0;i<n;i++) { printf("\nEnter the %d element",i); scanf("%d",&a[i]); } printf("\n\nElement you want to search:\n\n"); scanf("%d",&key); printf("\n**Non-Recursion method**\n"); nonreclinear(a,n,key); getch(); }/*end main*/ /* Non-Recursive method*/ void nonreclinear(int a[20],int n,int key) { int i, f=0; for(i=0;i<n;i++) { if( a[i] == key) { printf("\nThe element %d is present at position %d in list\n",key,i); f=1; break; } } if(f==0) printf("\nThe element is %d is not present in the list\n",key); }