Sunday, 12 January 2020



QUESTION:-LENEAR SEARCH



import java.util.*;
class lelenar
{
    void main()
    {int k=1;
        Scanner sc=new Scanner(System.in);
        System.out.println("ente the number to be search for");
        int x=sc.nextInt();
        int a[]=new int[10];
        for(int i=0;i<l;i++)
        {
            System.out.println("enter the "+k+" number ");
           a[i]=sc.nextInt();
           k=k+1;
        }
        boolean found=false;int p=0;
        for(int i=0;i<10;i++)
        {
            if(a[i]==x)
            {
                found=true;
                p=i+1;
                break;
            }
        }
        System.out.println("the position of no is"+p);
        if(found==true)
        System.out.println("search sucessfull");
            else
            System.out.println("search unsuccesfull");
        }

    }

No comments:

Post a Comment

HAY THAKYOU FOE VISIT

Program(python):-Find duplicates in an array (Geeks for geek problem)

QUESTION:- Given an array  a  of size  N  which contains elements from  0  to  N-1 , you need to find all the elements occurring more than o...