Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions Add Code Here/C++/Arrays/LinearSearch.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#include <iostream>
using namespace std;
int main(){
int A[10] = {10,512,8,82,8,55,44,55,45,45}, key;

int main() {
int A[10] = {10, 512, 8, 82, 8, 55, 44, 55, 45, 45};
int key;

cout << "Enter Key: ";
cin >> key;
for(int i =0; i< 10 ; i++){

if (key == A[i]){
cout << "Found at " << i << endl;
return 0;
}
for (int i = 0; i < 10; i++) {
if (key == A[i]) {
cout << "Found at index " << i << endl;
return 0;
}
}
cout << "Jane de n vro!";
}

cout << "Key not found!" << endl;

return 0;
}