title: Restrict user input to 5 digits in C
body: <p>I was assigned to make an user input a 5 digit number, validate it and print it back in a reversed order, I have the reverse part figured out yet I am struggling to figure out how to validate the variable in order to force the user to use 5 digits</p>
  <pre><code>#include &lt;stdio.h&gt;
  int main() {
      int n, inv = 0, inverso;
      printf(&quot;Introduce un numero de 5 digitos: &quot;);
      scanf(&quot;%d&quot;, &amp;n);
      while (n != 0) {
          inverso = n % 10;
          inv = inv * 10 + inverso;
          n /= 10;
      }
      printf(&quot;El numero invertido es = %d&quot;, inv);
      return 0;
  }
  </code></pre>