title: finding minimum of a subarray while the value might be only 1 or 2 or 3
body: <p><a href="http://justpaste.it/exc4" rel="nofollow">I have a problem</a> with the following code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  main()
    {
    int len,no,n,a,result;
    int start[100],end[100];
    int width[100];
  
    printf("enter the lenghth of the road : \n");
    scanf("%d",&amp;len);
  
    printf("enter the width of the road ,in unitwise format for the given length : \n");
    for(n=0;n&lt;len;n++)
      scanf("%d",&amp;width[n]);
  
    printf("enter the no of testcases : \n");
    scanf("%d",&amp;no);
  
    printf("for each testcase enter the starting and  end point : \n");
    for(n=1;n&lt;=no;n++){
      printf("for testcase %d enter the start and end point respectively",n);
      scanf("%d %d",&amp;start[n],&amp;end[n]);}
  
      for(n=1;n&lt;=no;n++){
          for(a=start[n];a&lt;=end[n];a++){
          result=3;
          if(width[a]&lt;result)
            result=width[a];
          }
  
        printf("for testcase %d the vehicle that can be used is %d",n,result);
        printf("\n");}
      }
  </code></pre>
  
  <p>I am not getting the right result although I feel I have applied right logic in finding minimum width. What is wrong with this logic?</p>