title: How to find largest and smallest number in c
body: <p>I have found the solution in particular size of array. 
  However, how can I get the largest and smallest numbers without asking to input the size of the array? thanks</p>
  
  <p>e.g. It will only return 65 and -1 when I input numbers like 1, 0, -1, 5, 43, 65. I want to ignore the step for entering the size of the array which is 6 for this case.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int main(){
    int a[50],size,i,big,small;
  
    printf("\nEnter the size of the array: ");
    scanf("%d",&amp;size);
    printf("\nEnter %d elements in to the array: ", size);
    for(i=0;i&lt;size;i++)
      scanf("%d",&amp;a[i]);
  
    big=a[0];
    for(i=1;i&lt;size;i++){
      if(big&lt;a[i])
        big=a[i];
    }
    printf("Largest element: %d",big);
  
    small=a[0];
    for(i=1;i&lt;size;i++){
      if(small&gt;a[i])
        small=a[i];
    }
    printf("Smallest element: %d",small);
  
    return 0;
  }
  </code></pre>