Ex - No:02 Linear Search: Aim: Sample Input Amd Output: Output
Ex - No:02 Linear Search: Aim: Sample Input Amd Output: Output
No:02
LINEAR SEARCH
AIM: To write a C++ program to search a given elements using fuctions.
OUTPUT:
#include<iostream.h>
#include<conio.h>
void main()
int AR[20],ITEM,N,index;
clrscr();
cin>>N;
for(int i=0;i<N;i++)
cin>>AR[i];
cin>>ITEM;
index=Lsearch(AR,N,ITEM);
if(index==-1)
}
else
getch();
for(int i=0;i<SIZE;i++)
if(AR[i]==ITEM)
return i;
return -1;
RESULT: Thus the given program is executed successfully and the output is verified.
OUTPUT:
10
10
(2)POSITION : 6