Sequence Search in C++
#include <iostream>#include <conio>
void main()
{
int arr[50],n,i,e;
cout<<"Enter the size of array "<<endl;
cin>>n;
for(i=0; i<=n; i++)
{
cout<<"Enter array element: "<<endl;
cin>>arr[i];
}
cout<<"Enter any number that you want to search "<<endl;
cin>>e;
for(i=0; i<=n; i++)
{
if(e==arr[i])
{
cout<<"Element is found at location "<<(i+1);
break;
}
}
if(i==n)
{
cout<<"Element is not found in this array "<<endl;
}
getch();
}
output Result:
Sequence Search |
Post a Comment