-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNineteen.java
42 lines (28 loc) · 996 Bytes
/
Nineteen.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
34
35
36
37
38
39
40
41
42
import java.util.Scanner;
public class Nineteen {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter the number of elements in a array");
int n= sc.nextInt();
int []arr=new int[100];
boolean isth=false;
for(int i=0;i<n;i++){
System.out.print("Enter the element " +i+ "-");
arr[i]=sc.nextInt();
}
System.out.println("Enter the number you want to see if present in the array");
int p=sc.nextInt();
for(int j=0;j<n;j++){
if(p==arr[j]){
isth=true;
}
if(isth==true){
System.out.println("It is present at-"+j+" Position");
break;
}
}
if(isth==false){
System.out.println("Not present");
}
}
}