title: How to find the smallest digit in a number and its position in a vector in C?
body: <p>Can someone please help me ? I need to put the number's digits into a vector, find the smallest digit among them, and print it along with its position in the vector.</p>
  
  <pre><code>    int main()
      {
          int n,i=0,v[100],Min=9,Position;
          scanf("%d",&amp;n);
          while(n!=0)
          {
              v[i]=n%10;
              if(v[i]&lt;Min)
              {
                  Min=v[i];
                  Position=i;
              }
              i++;
              n=n/10;
  
          }
          printf("%d, %d", Min, Position);
          printf("\n");
      }
  </code></pre>
  
  <p>input: 1234
  output: 1, 3 &lt;----  there is the problem, i can find the minimum digit but i can't get to show its position. instead of 0 it is 3, it counts from reverse input:2314
  output: 1, 1 &lt;-- should have been 1,2 </p>
  
  <p>Edit: Thank you "nicomp" now the final code looks like this.</p>
  
  <pre><code>int main()
  {
       {
          int n,m,i,v[100],Lenght=0,Min=9,Position;
          scanf("%d",&amp;n);
          m=n;
          while(m!=0)
          {
              m=m/10;
              Lenght++;
          }
          i=(Lenght-1);
          while(n!=0)
          {
              v[i]=n%10;
              if(v[i]&lt;Min)
              {
                  Min=v[i];
                  Position=i;
              }
              i--;
              n=n/10;
  
          }
          printf("%d, %d", Min, Position);
          printf("\n");
      }
  }
  </code></pre>