Computer Science, asked by pandulikhith3001, 11 months ago

Wap to input and store the names of all the students pf a class in an array namelist.Input the name of a student and check whether it is present in the array or not input using linear search

Answers

Answered by jhaashish501
1

int i,n,u=0,l=n,m=0;

String sv;

System.out.println("Enter the size of the array");

n= sc.nextInt();

String name = new String[n];

System.out.print("Enter the names");

for(i=0;i<n;i++)

{

s[i]=sc.next();

}

System.out.print("Enter the name to be searched");

sv=sc.next();

while(l<=u)

for(i=0;i<=n-1;i++)

{

if(a[i].compareTo(sv))

{

flag==1;

break;

}

if(flag==1)

System.out.println("Search value found ");

else

System.out.println("Search value not found ");

}



Similar questions