1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
int array[15]={28,3,16,4,3,16,5,8,4,12,5,4,8,21,40};
int x=0;
int done=0;
int item;
cout<<"Input an item to be searched:";
cin>>item;
while(done!=1&&x<15)
{
if(item==array[x])
{
cout<<"Found item"<<item<<" in the index of " <<x;
done=1;
}
else
{
x++;
}
}
cout<<" item "<<item<<" is not found";
|