-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsp_1.java
33 lines (31 loc) · 791 Bytes
/
sp_1.java
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
import java.util.*;
class sp_1
{
void main()
{
Scanner ob=new Scanner(System.in);
int s,i,n;
System.out.println("enter the no of elemente");
n=ob.nextInt();
int a[]=new int[n];
System.out.println("Enter those elements");
for(i=0;i<n;i++)
{
a[i]=ob.nextInt();
}
System.out.println("ENter the element to be searched");
s=ob.nextInt();
for(i=0;i<n;i++)
{
if(a[i]==n)
{
break;
}
}
if (i < n)
System.out.println( " found at index "
+ i + " in the array");
else
System.out.println( " not found in the array");
}
}