import java.util.*;
class Search
{
public static void main(String args[])
{
int i,sv,flag=0;
int nums[]=new int[10];
System.out.println("Enter numbers of the List");
Scanner f=new Scanner(System.in);
for(i=0;i<10;i++)
{
nums[i]=f.nextInt();
}
System.out.println("Enter the Search Value:");
sv=f.nextInt();
for(i=0;i<10;i++)
{
if(sv==nums[i])
{
flag=1;
System.out.println("Number is at nums["+i+"]="+nums[i]);
}
}
if(flag==1)
System.out.println("Number is found");
else
System.out.println("Number is not found");
}
}
class Search
{
public static void main(String args[])
{
int i,sv,flag=0;
int nums[]=new int[10];
System.out.println("Enter numbers of the List");
Scanner f=new Scanner(System.in);
for(i=0;i<10;i++)
{
nums[i]=f.nextInt();
}
System.out.println("Enter the Search Value:");
sv=f.nextInt();
for(i=0;i<10;i++)
{
if(sv==nums[i])
{
flag=1;
System.out.println("Number is at nums["+i+"]="+nums[i]);
}
}
if(flag==1)
System.out.println("Number is found");
else
System.out.println("Number is not found");
}
}
No comments:
Post a Comment