forked from krimanisha/Hacktoberfest21
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLinearSearch.cpp
More file actions
35 lines (31 loc) · 714 Bytes
/
LinearSearch.cpp
File metadata and controls
35 lines (31 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include<iostream>
using namespace std;
void lnr_srch(int a[] ,int n)
{
bool temp = true;
for(int i=0;i<5;i++)
{
if(a[i]==n)
{
cout<<"Value Found at position : "<<i+1;
temp = false;
break;
}
}
if(temp == true)
cout<<"Value Not Listed :(\n ";
}
int main()
{
int a[5];
cout<<"Enter five Element";
for(int i=0;i<5;i++)
{
cin>>a[i];
}
int srch_elmt;
cout<<"Enter The Element You Want To Search ?\n";
cin>>srch_elmt;
lnr_srch(a,srch_elmt);
return 0;
}