We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent de13931 commit a444326Copy full SHA for a444326
linearSearch.cpp
@@ -0,0 +1,41 @@
1
+#include<bits/stdc++.h>
2
+
3
+using namespace std;
4
+int linear_search(int DATA[],int n,int item)
5
+{
6
+ int loc=0;
7
8
+ for(int k=1;k<=n;k++)
9
+ {
10
+ if(DATA[k]==item)
11
+ { loc=k;
12
+ break;
13
+ }
14
15
+ if(loc==0)
16
17
+ cout<<"NOT FOUND";
18
19
+ else
20
21
+ cout<<"FOUND DATA["<<loc-1<<"]";
22
23
24
+}
25
26
+int main()
27
28
+ int DATA[100],n,item;
29
+ cout<<"HOW MANY NUMBERS U WANT TO ENTER ";
30
+ cin>>n;
31
+ cout<<"INPUT: ";
32
+ for(int i=1;i<=n;i++)
33
34
+ cin>>DATA[i];
35
36
+ cout<<"ITEM :";
37
+ cin>>item;
38
+ linear_search(DATA,n,item);
39
40
+ return 0;
41
0 commit comments