diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4db636a1..021d89f3 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -78,3 +78,5 @@ If you have contributed to this repository, kindly add your username here - [Pulkit Aggarwal](https://github.com/PulkitAgg) - [dius00](https://github.com/dius00) - [jayshah6699](https://github.com/jayshah6699) +- [Hardik Chitkara](https://github.com/hardikchitkara) + diff --git a/Linear Search/vikhyatsingh123_linear_search.cpp b/Linear Search/vikhyatsingh123_linear_search.cpp index 96aabd22..9a76ba71 100644 --- a/Linear Search/vikhyatsingh123_linear_search.cpp +++ b/Linear Search/vikhyatsingh123_linear_search.cpp @@ -7,9 +7,12 @@ int search(int array[], int n, int x) { // Going through array sequencially for (int i = 0; i < n; i++) + { if (array[i] == x) - return i; + {return i;} + } return -1; + } int main() { @@ -19,5 +22,5 @@ int main() { int result = search(array, n, x); - (result == -1) ? cout << "Element not found" : cout << "Element found at index: " << result; + (result == -1) ?cout << "Element not found" : cout << "Element found at index: " << result; }