Linear Search Values in Linear Array using C++
========================================================================
#include<iostream>
using namespace std;
main()
{
int arr[10]={10,40,11,15,9,11,6,3,7,99};
cout<<"Enter Number to Search in Array \n";
int item;
cin>>item;
int loc=0;
while(arr[loc]!=item)
{
loc++;
}
if(arr[loc]==item)
{
cout<<arr[loc]<<" Found in Index # "<<loc;
}
else
cout<<"not found in any Index\n";
}
========================================================================
0 comments:
Post a Comment