import java.util.*;
public class Linear_Search
{
public static void main()
{
Scanner sc = new Scanner(System.in);
int a[] = new int[10], i, pos=-1, s;
System.out.println("Enter 10 values for the array:");
for(i=0;i<10;i++)
{
a[i] = sc.nextInt();
}
System.out.println("Enter the value to search in the array:");
s = sc.nextInt();
//Linear Search
for(i=0;i<10;i++)
{
if(a[i]==s)
{
pos=i+1;
break;
}
}
if(pos!=-1)
System.out.println("Value is found at position: "+pos);
else
System.out.println("Value is not found");
}
}
Write a program to input an array of size 10 and another value to search in the array using Linear Search Method. If the number is found then print the position of the value else print appropriate message
Programming