Today I wrote a program in which I used scanf(). The program was correct but when I debugged it, the program was waiting for input even though I hit enter and didn't display the result until I pressed another number/character and then hit enter again. At that moment it showed the calculated value of input. I examined my code and found that I had placed a space after the format specifier. When I removed the space it worked fine.
`scanf("%d ",&a);`
What is the reason for this behavior?