You are close to satisfy the requirements. Try
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
int main(){
if( fork() == 0 )
{
for (;;)
{
printf("Child Process. parent process id is %u\n", getppid());
sleep(1);
}
}
else
{
for (;;)
{
printf("Parent Process.\n");
sleep(1);
}
}
return 0;
}