Skip to content

Commit

Permalink
Created linear search algorithm in cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishakhasarode authored Oct 23, 2022
1 parent 3265590 commit 44f47a8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions data-structure/Linear search.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<iostream>
using namespace std;
int main()
{
int arr[10], i, num, index;
cout<<"Enter 10 Numbers: ";
for(i=0; i<10; i++)
cin>>arr[i];
cout<<"\nEnter a Number to Search: ";
cin>>num;
for(i=0; i<10; i++)
{
if(arr[i]==num)
{
index = i;
break;
}
}
cout<<"\nFound at Index No."<<index;
cout<<endl;
return 0;
}

0 comments on commit 44f47a8

Please sign in to comment.