 <p>When the value for <code>scanf("%d",&amp;far);</code> is entered and press enter, the scanf stores the carriage return in the buffer. When it encounters the second scanf in the code <code>scanf("%c",&amp;ch);</code> it takes the carriage return present in the buffer as the input to 'ch'. So it doesn't wait for the user input.</p> <p>Please have a look at the post <a href="http://stackoverflow.com/questions/5240789/scanf-leaves-the-new-line-char-in-buffer">here</a></p> <p>As indicated in one of the reply the solution is to put a space in scanf</p> <pre><code>scanf(" %c",&amp;ch); </code></pre>