-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinear.java
More file actions
36 lines (33 loc) · 929 Bytes
/
linear.java
File metadata and controls
36 lines (33 loc) · 929 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
import java.util.*;
class linear
{
public static void main()
{
Scanner sc = new Scanner(System.in);
int num;
int pos = 0;
int found = 0;
int x[] = {63,17,96,38,3,43,35,82,57,90};
System.out.println("Enter the number to be searched : ");
num = sc.nextInt();
for(int i = 0; i < 10; i++)
{
if(x[i] == num)
{
found = 1;
pos = i;
break;
}
}
System.out.println("The array is : ");
for(int i = 0; i < 10; i++)
{
System.out.print(x[i] + " ");
}
System.out.println();
if(found ==1)
System.out.println("The number " + num + " was found at index number " + pos );
else
System.out.println("Not found in the array :( ");
}
}