fork system call and \n

hi,

i tried the following source codes:

fork1.c:
main()
{
printf("demo of fork\n");
fork();
printf("hello");
}

output:
demo of fork
hello hello

fork2.c:
main()
{
printf("demo of fork");
fork();
printf("hello");
}

output(fork2.c):
demo of fork
hello hello demo of fork

In both the programs chilld and parent process are supposed to execute the statement(here its printf("hello")) which is next to fork call.But why the printf("demo of fork") is getting executed twice.Pls clarify my doubt.

Thanks in advance.