-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchA.java
More file actions
49 lines (30 loc) · 713 Bytes
/
SearchA.java
File metadata and controls
49 lines (30 loc) · 713 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Search Element of Array
import java.util.*;
public class SearchA
{
public static void main(String args[])
{
int i,e,n;
Scanner sc=new Scanner(System.in);
System.out.println("eNTER THE sIZE oF aRRAY= ");
n=sc.nextInt();
int a[]=new int[n];
System.out.println("Enter the Array Element = ");
for(i=0;i<n;i++)
a[i]=sc.nextInt();
System.out.println("ENter the Emlemnt U want To Search");
e=sc.nextInt();
int temp=0;
System.out.print("Element ");
for(i=0;i<n;i++)
{
if(a[i]==e)
{
System.out.print(" "+a[i]);
++i;
temp=i;
}
}
System.out.print(" Found At "+temp);
}
}