Search an element in an Array of 20 integer
values.
(i) Use one Constructor to get input on variable and array.
(ii) Use one Constructor to Search the
Array.
(iii) Use a member function to display the
result.
(iv) Use Destructor in any suitable
position.
sir again same prb.program half post hocche
ReplyDeletesometimes its happened. you may try dropbox to share your file in public.
Delete#include
ReplyDeleteusing namespace std;
class earray
{
public:
int rem=0,a[20],inp,i;
earray();
~earray();
void display();
};
earray::earray()
{
cout<<"Enter the values:"<>a[i];
}
earray::~earray()
{
cout<<"Destructing"<>inp;
for(i=0;i<20;i++)
{
if(a[i]==inp)
{
cout<<"found"<<endl;
rem=1;
break;
}
}
if(rem==0)
cout<<"Not found"<<endl;
}
int main()
{
earray ar;
ar.display();
}
found correct
Delete#include
ReplyDeleteusing namespace std;
class search_array
{
public:
int i,t=0,inp;
search_array();
~search_array();
void show();
};
search_array :: search_array()
{
//cin>>max;
int a[10];
for(i=0; i<10; i++)
cin>>a[i];
}
search_array :: ~search_array()
{
cout<<"\ndestructing" ;
}
void search_array :: show()
{
int a[i];
cin>>inp;
for(i=0; i<10; i++)
{
if(a[i]==inp)
{
cout<<"found" ;
break;
t=1;
}
}
if(t=0)
cout<<"not found" ;
}
int main()
{
search_array sa;
sa.show();
}
found correct
DeleteMohammad Ashraful Hasan sobuj
ReplyDeleteCSE-46(Dip)
ID=201420656
#include
using namespace std;
class earray-search
{
public:
int elmt=0,x[20],inp,i;
earray();
~earray();
void proved();
};
earray::earray()
{
cout<<"the elements:"<>x[i];
}
earray::~earray()
{
cout<<"destructing"<>inp;
for(i=0;i<20;i++)
{
if(x[i]==inp)
{
cout<<"found"<<endl;
elmt=1;
break;
}
}
if(elmt==0)
cout<<"Not found"<<endl;
}
int main()
{
search-earray sa;
sa.proved();
}
#include
ReplyDeleteusing namespace std;
class evensum
{
public:
void setnum(int n)
{
number =n;
}
protected: int number;
};
class findsum: public evensum
{
public:
void getsum()
{
int temp,i,a[100],sum=0;
temp=number;
cout<<"Enter "<>a[i];
}
for (i=0;i>n;
es.setnum(n);
es.getsum();
return 0;
}
sonia ferdusi
ReplyDeleteid:201410285,batch:45
#include
using namespace std;
class search_array
{
public:
int i,t=0,inp;
search_array();
~search_array();
void show();
};
search_array :: search_array()
{
//cin>>max;
int a[10];
for(i=0; i<10; i++)
cin>>a[i];
}
search_array :: ~search_array()
{
cout<<"\ndestructing" ;
}
void search_array :: show()
{
int a[i];
cin>>inp;
for(i=0; i<10; i++)
{
if(a[i]==inp)
{
cout<<"found" ;
break;
t=1;
}
}
if(t=0)
cout<<"not found" ;
}
int main()
{
search_array sa;
sa.show();
}