#include using namespace std; class searc { public: searc() { int DATA[10]={1,2,3,4,5,6,7,8,9,19}; int N,LOC,K,ITEM; N=10; K=0; LOC=11; ITEM=5; while(LOC==11 && K<N) { if(ITEM==DATA[K]) LOC=K; K=K+1; } if(LOC==11) cout<<"Item is not in array"<<endl; else cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";
#include using namespace std; class searc { public: searc() { int DATA[10]={1,2,3,4,5,6,7,8,9,19}; int N,LOC,K,ITEM; N=10; K=0; LOC=11; ITEM=22; while(LOC==11 && K<N) { if(ITEM==DATA[K]) LOC=K; K=K+1; } if(LOC==11) cout<<"Item is not in array"<<endl; else cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";
#include using namespace std; class linear { public: int DATA[8]={2,3,4,5,6,7,8,9},n=8,item=5,k=0,loc=-1; linear() { while(loc==-1 && k<n) {
if(item==DATA[k]) loc=k; k+=1; } if(loc==-1) cout<<"item is not present"<<endl; else cout<<"the locatiion of the item="<<loc<<endl; } }; int main() { linear l; }
#include using namespace std; class searc { public: searc() { int DATA[10]={1,2,3,4,5,6,7,8,9,19}; int N,LOC,K,ITEM; N=10; K=0; LOC=11; ITEM=22; while(LOC==11 && K<N) { if(ITEM==DATA[K]) LOC=K; K=K+1; } if(LOC==11) cout<<"Item is not in array"<<endl; else cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";
#include
ReplyDeleteusing namespace std;
class searc
{
public:
searc()
{
int DATA[10]={1,2,3,4,5,6,7,8,9,19};
int N,LOC,K,ITEM;
N=10;
K=0;
LOC=11;
ITEM=5;
while(LOC==11 && K<N)
{
if(ITEM==DATA[K])
LOC=K;
K=K+1;
}
if(LOC==11)
cout<<"Item is not in array"<<endl;
else
cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";
}
};
int main()
{
searc c;
}
// with destructor
ReplyDelete#include
using namespace std;
class searc
{
public:
searc()
{
int DATA[10]={1,2,3,4,5,6,7,8,9,19};
int N,LOC,K,ITEM;
N=10;
K=0;
LOC=11;
ITEM=22;
while(LOC==11 && K<N)
{
if(ITEM==DATA[K])
LOC=K;
K=K+1;
}
if(LOC==11)
cout<<"Item is not in array"<<endl;
else
cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";
}
~searc()
{
}
};
int main()
{
searc c;
}
#include
ReplyDeleteusing namespace std;
class linear
{
public:
int DATA[8]={2,3,4,5,6,7,8,9},n=8,item=5,k=0,loc=-1;
linear()
{
while(loc==-1 && k<n)
{
if(item==DATA[k])
loc=k;
k+=1;
}
if(loc==-1)
cout<<"item is not present"<<endl;
else
cout<<"the locatiion of the item="<<loc<<endl;
}
};
int main()
{
linear l;
}
#include
ReplyDeleteusing namespace std;
class linear
{
public:
int DATA[8]={2,3,4,5,6,7,8,9},n=8,item=5,k=0,loc=-1;
linear()
{
while(loc==-1 && k<n)
{
if(item==DATA[k])
loc=k;
k+=1;
}
if(loc==-1)
cout<<"item is not present"<<endl;
else
cout<<"the locatiion of the item="<<loc<<endl;
}
~linear()
{
}
};
int main()
{
linear l;
}
#include
ReplyDeleteusing namespace std;
class searc
{
public:
searc()
{
int DATA[10]={1,2,3,4,5,6,7,8,9,19};
int N,LOC,K,ITEM;
N=10;
K=0;
LOC=11;
ITEM=22;
while(LOC==11 && K<N)
{
if(ITEM==DATA[K])
LOC=K;
K=K+1;
}
if(LOC==11)
cout<<"Item is not in array"<<endl;
else
cout<<"Item is in " << " "<<LOC<<"th"<< " "<<"position of array";
}
~searc()
{
}
};
int main()
{
searc c;
}
#include
ReplyDeleteusing namespace std;
class searc
{
public:
int DATA[5]={1,2,3,4,5},item=2,n=5,loc=-1,k=0;
searc()
{
while(loc==-1&&k<n)
{
if(item==DATA[k])
loc=k;
k=k+1;
}
if(loc==-1)
cout<<"item is not present"<<endl;
else
cout<<"The location of item is="<<loc<<endl;
}
~searc()
{
}
};
int main()
{
searc s;
}