title: Nested if structure in c not working the way expected
body: <p>I am a beginning programmer who has made little number-guessing code here as an exercise. The c code here does not print "Correct!" if a user guesses the right number. Why is this nested if structure not working?
  <strong>strong text</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;time.h&gt;
  
  int main()
  {
      int iRandomNum = 0;
      char cUserInput = 0;
      srand(time(NULL));
      iRandomNum = (rand() % 10) + 1;
  
      printf("Guess a number between 1 to 10:");
      scanf("%c", &amp;cUserInput);
  
      if(isdigit(cUserInput))
      {
          if(cUserInput==iRandomNum)
            printf ("Correct!");
          else
            printf("The right answer was %d", iRandomNum);
      }
      else
        printf("You did not enter a digit.");
  
        return 0;
  
  }
  </code></pre>