-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlec10.java
More file actions
39 lines (34 loc) · 1.05 KB
/
Copy pathlec10.java
File metadata and controls
39 lines (34 loc) · 1.05 KB
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
package arrays;
import java.util.*;
public class lec10 {
public static void main(String args[]){
// initialization
// int[] marks = new int[100];
// marks[0] = 97;
// marks[1] = 85;
// marks[2] = 33;
// System.out.println(marks[0]);
// System.out.println(marks[1]);
// System.out.println(marks[2]);
// for(int i=0; i<3; i++){
// System.out.println(marks[i]);
// }
Scanner sc = new Scanner(System.in);
System.out.println("enter the input for the arrays-");
int size = sc.nextInt();
int numbers[] = new int[size];// defining arrays
// input
for(int i=0; i<size; i++){
numbers[i] = sc.nextInt();
}
System.out.println("print the value to find");
int x = sc.nextInt();
//output
for(int i=0; i<numbers.length; i++){
System.out.println(numbers[i]);
if(numbers[i] == x){
System.out.println("found at index:" +i);
}
}
}
}