Need urgent help with fork()

Hy!

I must wrote some code with fork() command. The thing is that i have a while statement which count till 10.

I must wrote a program that one child has only one parent. So one parent has only one child and one child has only one parent. Can you please help me with these code.

int main()
{
int N,i,pid = 0;
scanf("%d",&N);
while(i <= N)
{
   pid = fork();
   if (pid == 0)
     {
       printf("child proc %d = %x\n", i, getpid());
       wait(NULL);
     }
    if(pid != 0)
    {
      printf("Parent proc %d = %x\n", i, getppid());
      exit(0);
    }
    i++;
}
}

What i'm doing wrong. Please help!

int N,i,pid = 0;
/* should be */
int N=0,
    i=0;
pid_t pid=0;

Ok i have change that. But my code still don't do it wright, so please help me. I must get out one parent - one child.