Program not asking expected number of values <pre><code>#include &lt;stdio.h&gt; main() { int n,i; FILE *fptr; fptr=fopen("f3.txt","w"); if(fptr==NULL) { printf("Error!"); exit(1); } printf("Enter n: "); for(i=0;i&lt;=2;i++) { scanf("%d \n",&amp;n); fprintf(fptr,"%d ",n); } fclose(fptr); return 0; } </code></pre> <p><strong>EDIT:</strong> *<em>In the above program, I am entering 3 values, but why this is asking for 4 values? Although its writing only three times but its asking for the values 4 times. Can u tell d reason? And what to do to make it to take exact number of values which I am typing.?</em>* thanks in advance..</p> <p><strong>So this is known that it was due to space next to %d in loop. Can someone explain Carriage Return in a little detail, I searched but could not understand exactly what that is.</strong></p>