Flush the output stream before calling scanf.
If you print with a newline at the end, it will flush the output. Without, it may or may not. It doesn't have to. So it's really dependant on your OS / compiler / whatever it feels like.
int a, b;
printf("Enter 2 numbers:");
fflush( stdout );
scanf("%d %d", &a, &b);
printf("%d %d", a, b);
fflush is only designed for output streams. You can't flush input with it. Or rather, it's undefined behaviour if you try it.
printf("foo\n"); /* flushes output... */
printf("bar" ); /* doesn't */