Sunday, 12 January 2020

HAY THANK FOR VISIT


Question:-Write a program to print the smallest number in array.


class Small

{


      void main(int a[])
            {
               int l=a.length;
                int s=a[0];
                 int p=0;
                 for(int i=1;i<l;i++)
                      {
                            if(a[i]<s)
                              {
                                 s=a[i];
                                 p=i;
                               }
                        }
         System.out.println("the smallest element  in the arayyis"+s);
          System.out.println("position of element is"+p);

                 }
  }

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...