-
Notifications
You must be signed in to change notification settings - Fork 2
/
c2.cpp
36 lines (34 loc) · 803 Bytes
/
c2.cpp
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;
int main()
{
int arr[100], i, num, n, found=0, pos;
cout<<"\n Enter Array Size : ";
cin>>n;
cout<<"\n Enter Array Elements : \n";
for(i=0; i<n; i++)
{
cout<<" ";
cin>>arr[i];
}
cout<<"\n Enter Element to be Searched : ";
cin>>num;
for(i=0; i<n; i++)
{
if(arr[i]==num)
{
found=1;
pos=i+1;
break;
}
}
if(found==0)
{
cout<<"\n Element Not Found..!!";
}
else
{
cout<<"\n Element "<<num<<" Found At Position "<<pos;
}
return 0;
}