LNRSRCH - clrscr(); printf("Enter the no of...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<stdio.h> #include<conio.h> # /* RISHI AGARWAL LINEAR SEARCH ROLL NO 02 SE CMPN A */ * #define max 20 # void display(int a[],int n) { int i; printf("\nLIST\n"); for(i=0;i<n;i++) printf("%d ",a[i]); } void isort(int arr[],int n) { int i,j,x; for(i=1;i<=n-1;i++) { x=arr[i]; j=i; { arr[j]=arr[j-1]; j--; } arr[j]=x; } } void seqsearch(int a[],int n,int k) { int i=0; i++; if(a[i]==k) printf("The elment %d is found at position %d",a[i],i+1); else printf("Element Not Found"); } void main() { int n,i,k,arr[max];
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: clrscr(); printf(&quot;Enter the no of data:&quot;); scanf(&quot;%d&quot;,&amp;n); printf(&quot;Enter the nos&quot;); for(i=0;i&lt;n;i++) scanf(&quot;%d&quot;,&amp;arr[i]); //Displaying List display(arr,n); //Insertion Sort isort(arr,n); //Displaying Sorted List display(arr,n); printf(&quot;\nEnter the key:&quot;); scanf(&quot;%d&quot;,&amp;k); seqsearch(arr,n,k); getch(); } /* OUTPUT: Enter the no of data:6 Enter the nos2 89 44 72 56 31 LIST 2 89 44 72 56 31 LIST 2 31 44 56 72 89 Enter the key:72 The elment 72 is found at position 5 */...
View Full Document

Page1 / 2

LNRSRCH - clrscr(); printf(&amp;amp;quot;Enter the no of...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online