#include<iostream.h>
#include<conio.h>
class linear( )
{
private:
int i, m, a[10], n, t;
public:
void get( );
void search( );
};
void linear :: get( )
{
cout<<”\nEnter the limit : “;
cin>>n;
cout<<”\nEnter the elements : “;
for(i=0; i<n ; i++)
cin>>a[i];
}
void linear :: serach( )
{
cout<<”\nEnter the element to be serached : “;
cin>>m;
for(i=0 ; i<n; i++)
{
if(a[i]==m)
{
t=1;
break;
}
}
if(t==1)
cout<<”\nElement is found”;
else
cout<<”\nElement is not found”;
}
void main( )
{
clrscr( );
linear l;
l.get( );
l.search( );
getch( );
}
Linear Search-C++
Share This!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment