Skip to content

Commit b3fc62d

Browse files
Merge pull request #764 from ask2sm/patch-33
searcharray.cpp
2 parents eaa346f + 6099d17 commit b3fc62d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

searcharray.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<bits/stdc++.h>
2+
using namespace std;
3+
4+
int main(){
5+
int n;
6+
cout<<"Enter size of the array:"<<endl;
7+
cin>>n;
8+
int arr[n];
9+
cout<<"Enter array elements:"<<endl;
10+
for(int i=0;i<n;i++)
11+
cin>>arr[i];
12+
int x;
13+
cout<<"Enter number to be found:"<<endl;
14+
cin>>x;
15+
//search
16+
for(int i=0;i<n;i++){
17+
if(arr[i]==x){
18+
cout<<"Element found at:"<<i+1<<endl;
19+
}
20+
}
21+
return 0;
22+
}

0 commit comments

Comments
 (0)