Skip to content

Commit 5e977b4

Browse files
authored
Update LinearSearch.cpp
1 parent d76c180 commit 5e977b4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

C++/Algorithms/Searching-Algorithms/LinearSearch.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@
55
#include <iostream>
66
using namespace std;
77

8-
int search(int arr[], int n, int x)
8+
int search(int arr[], int n, int y)
99
{
1010
int i;
1111
for (i = 0; i < n; i++)
12-
if (arr[i] == x)
12+
if (arr[i] == y)
1313
return i;
1414
return -1;
1515
}
1616

1717
int main(void)
1818
{
1919
int arr[] = { 2, 3, 4, 10, 40 };
20-
int x = 10;
20+
int y = 10;
2121
int n = sizeof(arr) / sizeof(arr[0]);
22-
int result = search(arr, n, x);
22+
int result = search(arr, n, y);
2323
(result == -1)? cout<<"Element is not present in array"
2424
: cout<<"Element is present at index " <<result;
2525
return 0;

0 commit comments

Comments
 (0)