can anyone solve this program please
Answers
Answer:
import java.util.Scanner; //or import java.util.*;
public class LinearSearch{
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int arr[] = new int[20];
int i, SEARCHELEMENT, counter=0;
for(i=0; i<arr.length; i++){
System.out.print("Enter element no. " + (i+1) + " : ");
arr[i]=sc.nextInt(); //after the user presses enter key, the control will shift to next line
}
System.out.print("Enter the search element: ");
SEARCHELEMENT = sc.nextInt();
for(i=0; i<arr.length; i++){
if(SEARCHELEMENT == arr[i])
counter++;
}
if(counter>0)
System.out.print("The search element appeared " + counter + " times.");
else
System.out.print("Search element is not present in the given array!");
}
}
Please mark as brainliest!