# C++ Linked list problem, computer science homework help

According to the file that i uploaded, I have to write add polynomial function

so far I wrote like this and it does not work

how can I fix this code?

void add (List &polyZ, List &polyF, List &poly G)

{

Node *pN_Z,*pN_F;

int icoeff,ideg;

while(pN_Z!=NULL && pN_F=NULL)

{

if(pN_Z->ideg==pN_F->ideg)  // deg is equal

{

icoeff=pN_Z->icoeff+pN_F->icoeff;

ideg=pN_Z-> ideg;

pN_Z= pN_Z->next;

pN_F= pN_F->next;

}

else if(pN_Z->ideg > pN_F->ideg)

{

icoeff = pN_Z->icoeff;

ideg = pN_Z->ideg;

pN_Z = pN_Z->next;

}

else if(pN_Z->ideg <pN_F->ideg)

{

icoeff = pN_F->icoeff;

ideg = pN_F->ideg;

pN_F = pN_F->next;

}

ptrn=new node;

ptrn->icoeff= icoeff;

ptrn-> ideg= ideg ;

ptrn-> next=NULL;

ptrp->next=ptrn;

ptrp=ptrn;

} // End of While

if(pN_Z==NULL)

{

while(pN_F!=NULL)

{

icoeff =pN_F->icoeff;

ideg = pN_F->ideg;

pN_F= pN_F->next;

ptrn=new node;

ptrn->icoeff=icoeff;

ptrn->ideg=ideg;

ptrn->next=NULL;

ptrp->next=ptrn;

ptrp=ptrn;

}

}

else if(pN_F==NULL)

{

while(pN_Z!=NULL)

{

icoeff =pN_Z->icoeff;

ideg = pN_Z->ideg;

pN_Z= pN_Z->next;

ptrn=new node;

ptrn->icoeff=icoeff;

ptrn->ideg=ideg;

ptrn->next=NULL;

ptrp->next=ptrn;

ptrp=ptrn;

}

}