Skip to content

Instantly share code, notes, and snippets.

@ahmedengu
Created March 9, 2016 04:06
Show Gist options
  • Save ahmedengu/c7a5c1853079bce3b6fc to your computer and use it in GitHub Desktop.
Save ahmedengu/c7a5c1853079bce3b6fc to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
void linearSearch(int target){
int arr[] = {1,5,9,8,9,4,7,5,6,3,1,7};
int size=12;
for (int i = 0; i < size; i++) {
if(target == arr[i]){
cout<<endl<<"found at :"<<i;
return;
}
}
cout<<"not found";
}
int main() {
linearSearch(7);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment