It's just a guess since you didn't post the version that didn't work but if you didn't wrap the functions in a blocl it would exhibit the behavior described.
i.e.
Code:
for (i = 0; i < 10 ; i++)
printf("enter a number: \n"); scanf("%d", &a[i]);
copy and paste this to your favorite editor, compile and see if it works.
Code:
#include <stdio.h>
#include <stdlib.h>
int main() {
int i;
int a[10] = {0};
for (i = 0; i < 10; i++) {
printf ("enter number %d:", i);
fflush (stdout);
scanf ("%d", &a[i]);
}
for (i = 0; i < 10; i++) {
printf ("%d: %d\n", i, a[i]);
}
return 0;
}
On my system it works without flushing stdout but GazL is correct in saying it's the right thing to do. In your example the \n will flush the stream.