Process creation in Unix with C Program

Hi,

can somebody please help me regarding this?
How can i print parent's PID from child's and vice versa.

I have tried with getpid() & ngetppid() function but it is not giving me the correct data. The logic i used is:

if (pid == 0)
{
getpid() : Chil'd PID
getppid(): Parent;s PID
}
else
{
getpid(): Parent's PID;
pid: Child' PID;
}

Output should match, right? But is is not matching.

If you have idea, please let me know.

With regards,
Sudipta

pid=fork();

I do not see fork()....