Sunday, 3 March 2013

Sequential Search Program in JAVA

Sequential search program in java

class Sequentialsearch
{
void search(int a[],int x)
{

for(int i=0;i<11;i++)
{
if(a[i]==x)
System.out.println("a["+i+"] = "+a[i]);
else
System.out.println("Not found");
}
}
}
class Sequentialsearchmain
{
public static void main(String args[])
{
Sequentialsearch s=new Sequentialsearch();
int arr[]={4,1,5,7,9,3,4,6,8,5,2};
s.search(arr,6);
}
}

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel