class cons { public: cons(int i, int arr[]); ~cons(); };
cons::cons(int i, int arr[]) { int chk = 0; for (int j = 0; j < 10; j++){ if (i == arr[j]){ cout << "Number found......"; j = 10; chk = 1; } else chk = 0; } if (chk == 0) cout << "Number not found...."; }
cons::~cons() {
}
int main() { int arr[10], key; for (int i = 0; i < 10; i++){ cout << "Enter " << i+1 << " Number --: "; cin >> arr[i]; } cout << "Enter the number for search --: "; cin >> key;
///Tisha ///201930034 #include int main() { int arr[10], Size, i, Search, Flag; printf("\n Enter the size of an array :"); scanf("%d",&Size); printf("\n Enter %d elements of an array:\n", Size); for(i = 0; i < Size; i++) { scanf("%d",&arr[i]); } printf("\n Enter the Search Element : "); scanf("%d",&Search); Flag = 0; for(i = 0; i < Size; i++) { if(arr[i] == Search) { Flag = 1; break; } } if(Flag == 1) { printf("\n the Search Element %d at Position %d ", Search, i + 1); } else { printf("\n the Search Element doesn't found %d ", Search); } return 0; }
#include
ReplyDeleteusing namespace std;
class sarray
{
public:
int rem=0,a[10],i,p;
sarray();
~sarray();
void show();
};
sarray::sarray()
{
for(i=0;i<10;i++)
cin>>a[i];
}
sarray::~sarray()
{
cout<<"distructing"<>p;
for(i=0;i<10;i++)
{
if(a[i]==p)
{
cout<<"found"<<endl;
rem=1;
break;
}
}
if(rem==0)
cout<<"Not found"<<endl;
}
int main()
{
sarray sa;
sa.show();
}
its correct.
Delete#include
ReplyDeleteusing namespace std;
class sarray
{
public:
sarray();
~sarray();
void show();
};
sarray::sarray()
{
int a[10],r,x;
for(r=0;r<10;r++)
cin>>a[r];
}
sarray::~sarray()
{
cout<<"Destructing";
}
void sarray::show()
{
cout<<"Enter on element"<>x;
for(r=0;r<10;r++)
{
if(a[r]==x)
{
cout<<"Array Found"<<endl;
break;
}
if(a[r]==0)
{
cout<<"Array Not Found"<<endl;
}
}
}
int main()
{
sarray sa;
sa.show();
}
Its Correct
DeleteIts better to declare variable in base class under public: section
Delete#include
ReplyDeleteusing namespace std;
class sarray
{
public:
int t=0,m[10],i,n;
sarray ();
~sarray();
void show();
};
sarray:: sarray()
{
for(i=0;i<10;i++)
cin>>m[i];
}sarray:: ~sarray()
{
cout<<"destructing"<>n;
for(i=0;i<10;i++)
{
if(m[i]==n)
{
cout<<"found"<<endl;
t=1;
break;
if(t==0)
cout<<"not found"<<endl;
}
}
int main()
{
sarray sa;
sa.show();
}
}
Its correct
DeleteDear sir Please visit below link:
ReplyDeletehttp://itlearn24.blogspot.com/2014/11/search-element-in-array-of-n-integer.html
noted and found correct
Delete#include
ReplyDeleteusing namespace std;
class cons
{
public:
cons(int i, int arr[]);
~cons();
};
cons::cons(int i, int arr[])
{
int chk = 0;
for (int j = 0; j < 10; j++){
if (i == arr[j]){
cout << "Number found......";
j = 10;
chk = 1;
}
else
chk = 0;
}
if (chk == 0)
cout << "Number not found....";
}
cons::~cons()
{
}
int main()
{
int arr[10], key;
for (int i = 0; i < 10; i++){
cout << "Enter " << i+1 << " Number --: ";
cin >> arr[i];
}
cout << "Enter the number for search --: ";
cin >> key;
cons obj(key, arr);
return 0;
}
///Tisha
ReplyDelete///201930034
#include
int main()
{
int arr[10], Size, i, Search, Flag;
printf("\n Enter the size of an array :");
scanf("%d",&Size);
printf("\n Enter %d elements of an array:\n", Size);
for(i = 0; i < Size; i++)
{
scanf("%d",&arr[i]);
}
printf("\n Enter the Search Element : ");
scanf("%d",&Search);
Flag = 0;
for(i = 0; i < Size; i++)
{
if(arr[i] == Search)
{
Flag = 1;
break;
}
}
if(Flag == 1)
{
printf("\n the Search Element %d at Position %d ", Search, i + 1);
}
else
{
printf("\n the Search Element doesn't found %d ", Search);
}
return 0;
}
//jamil zilani
ReplyDelete//201930092
#include
using namespace std;
class A
{
public:
int n[10];
int i,j;
A()
{
for ( i = 0; i<10; i++ )
{
cout << "Enter value of n[" << i << "]"<< endl;
cin >> n[i];
}
for (j = 0; j < 10; j++ )
{
cout << "n[" << j << "] = " << n[j] << endl;
}
}
~A()
{
}
};
int main()
{
A obj;
}
https://drive.google.com/file/d/1S299G14GftDEQ8s3gMQmRemRGuKeKcZ3/view?usp=sharing
ReplyDeleteFARJANA KAMAL KONOK
ReplyDelete201930701
using namespace std;
class sarray
{
public:
int t=0,m[10],i,n;
sarray ();
~sarray();
void show();
};
sarray:: sarray()
{
for(i=0;i<10;i++)
cin>>m[i];
}sarray:: ~sarray()
{
cout<<"destructing"<>n;
for(i=0;i<10;i++)
{
if(m[i]==n)
{
cout<<"found"<<endl;
t=1;
break;
if(t==0)
cout<<"not found"<<endl;
}
}
int main()
{
sarray sa;
sa.show();
}
}