Back
Uncategorized

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;
   
   head=ptrn= ptrp = NULL;
   pN_Z =Z.head;
   pN_F =F.head;
   
   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;
      if(head==NULL)
 head =ptrn;
      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;
if(head==NULL)
   head=ptrn;
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;
if(head==NULL)
   head=ptrn;
ptrn->icoeff=icoeff;
ptrn->ideg=ideg;
ptrn->next=NULL;
ptrp->next=ptrn;
ptrp=ptrn;
      }
   }
}  // End of addition

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount! Use Discount Code “Newclient” for a 15% Discount!NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.

The post C Linked list problem computer science homework help appeared first on Nursing Writers Hub.