Write a program to create an integer array marks[6] with the following
elements .
{56,89,100,45,78,85}
Input a mark to be searched for, and check whether it is present or not
using Linear search technique. If present,print the mark is present
Otherwise print mark is not present.
Answers
Answered by
1
Answer: Java Program
import java.util.*;
class demo{ //declare class
public static void main(String []args){ //declare main function
Scanner sc = new Scanner(System.in);
int marks[ ] = {56,89,100,45,78,85};
System.out.print("Enter the no. to be searched:");
int find = sc.nextInt( );
for (int i = 0; i < 6; i++){ //declare for loop
if (find == marks[i]) {System.out.println("the mark is present"); }
else {System.out.println("mark is not present");}
} //end of for loop
} //end of main function
} //end of class
Similar questions