title: Java program to find the largest & smallest number in n numbers without using arrays
body: <p>I could get the largest without using arrays but, unable to get the smallest one.</p>
  
  <pre><code>    public static void main(String[] args)
      {
          int smallest=0;
          int large=0; 
          int num;
  
          System.out.println("enter the number");
  
          Scanner input=new Scanner(System.in);
  
          int n=input.nextInt();
  
          for(int i=0;i&lt;n;i++)
          {
            num=input.nextInt();
            if(num&gt;large)
            {
             large=num;
            }
            System.out.println("the largest is:"+large);
            //gives the largest number in n numbers
  </code></pre>
  
  <p>code for the smallest..</p>
  
  <pre><code>     if(i==0&amp;&amp;num&gt;0)
           small=num;
       if(num&lt;small)
          small=num;
       System.out.println(small);
  
        }
  </code></pre>