using namespace std;
int main()
{
int array[10],findNum,index,i,j,k=0;
cout<<"Enter 10 numbers in array : \n";
for(i=0;i<10;i++)
{
cout<<"Enter number "<<i+1<<": ";
cin>>array[i];
}
cout<<"\n\nEnter number to find in array ";
cin>>findNum;
for(j=0;j<10;j++)
{
if(findNum==array[j])
{
cout<<"\nThe number found in array is "<<array[j]<<endl;
index=j;
cout<<"The index of number found in array is "<<index<<endl;
}
else
{
++k;
}
if(k==10)
{
cout<<"\nThe number "<<findNum<<" not found in array "<<endl;
}
}
}
No comments:
Post a Comment