Runtime Error Of Scanf(); : <p>In following c code scanf is not working.
When program is run, it execute upto the second printf line and after it skips the  scanf("%c",&amp;sex); and directly execute next printf().
Why this so happen?
I run this code on different c compilers, but the output is same.</p>

<pre><code>#include&lt;stdio.h&gt;
void main()
{
  char mar,sex;
  int age,flag=0;

  printf("Married [Y/N]:");
  scanf("%c",&amp;mar);

  printf("Sex [M/F] :");
  scanf("%c",&amp;sex);   //**This not working**

  printf("Age :"); //**execution directly jumped here**
  scanf("%d",&amp;age);

  if(mar=='y')
    flag=1;
  else if(sex=='m'&amp;&amp; age&gt;=30)
    flag=1;
  else if(sex=='f'&amp;&amp; age&gt;=25)
    flag=1;
  else
  {
  }
  if(flag)
  {
    printf("Congratulations!!!! You are Egligible..");
  else
    printf("Sorry... You are not egligible..");

getch();
}
</code></pre>

<p>//Output</p>

<pre><code>Married [Y/N]:y
Sex [M/F] :Age :23
Congratulations!!!! You are Egligible..
</code></pre>
