Write a
program to enter 10 elements in an anrrays
and search for a given numbers in the arrays
by using linear Search technique anel
print the
programe
Answers
Answered by
1
import java.util.Scanner;
public class j
{
public static void main(String[] str){
String[] elements = {"Oxygen", "Hydrogen", "Helium", "Carbon", "Argon", "Titanium", "Chromium", "Neon", "Sodium", "Sulfur"};
System.out.println("Enter Query: ");
Scanner input = new Scanner(System.in);
int search = input.nextInt();
System.out.println(elements[search]);
// Note: Any array starts with 0.
}
}
Similar questions