-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_number_in_array.java
More file actions
54 lines (37 loc) · 981 Bytes
/
Copy pathcheck_number_in_array.java
File metadata and controls
54 lines (37 loc) · 981 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
50
51
52
53
54
import java.util.*;
//Check if a key is present in every segment of size k in an array
public class check_number_in_array {
public static void main(String[] args) {
// TODO Auto-generated method stub
int n;
Scanner input=new Scanner(System.in);
System.out.print("Enter the number of element you want to enter");
n=input.nextInt();
System.out.println();
System.out.print("Enter the elements here");
int [] x=new int[n];
for(int i=0;i<n;i++)
{
x[i]=input.nextInt();
}
System.out.println();
System.out.print("entered array is " );
for(int i=0;i<n;i++)
{
System.out.print(x[i]+ " ");
}
System.out.println();
int no;
System.out.print("Enter the number you want to search");
no=input.nextInt();
for(int i=0;i<n;i++)
{
if(x[i]==no);
{
System.out.println();
System.out.print("Element found");
}
input.close();
}
}
}