title: Program to find largest and second largest number in array
body: <p>I have searched many websites for this question. They are doing it by some different approach.
  This code is just not giving output if I input first element of array as largest i.e. <code>a[0]</code>.
  I think some minor change is required.
  can anyone please tell me?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      int a[10], n;
      int largest1, largest2, i;
  
      printf("enter number of elements you want in array");
      scanf("%d", &amp;n);
      printf("enter elements");
      for (i = 0; i &lt; n; i++) {
          scanf("%d", &amp;a[i]);
      }
      largest1 = a[0];
      for (i = 0; i &lt; n; i++) {
          if (a[i] &gt; largest1) {
              largest1 = a[i];
          }
      }
      largest2 = a[0];
      for (i = 1; i &lt; n; i++) {
          if (a[i] &gt; largest2 &amp;&amp; a[i] &lt; largest1)
              largest2 = a[i];
      }
      printf("First and second largest number is %d and %d ", largest1, largest2);
  }
  </code></pre>