Polynomial using Lists ppt presentation in c

srilathabala7 8 views 6 slides Jul 29, 2024
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

polymerisation ppt concept


Slide Content

Polynomial Addition using Linked Lists K Mahesh

struct node { int co, expo; struct node* next; };

struct node* polyCreate ( struct node* head, int co, int expo) { struct node *temp, * newNode ; newNode = ( struct node *) malloc ( sizeof ( struct node)); newNode ->co = co; newNode ->expo = expo; newNode ->next = NULL; //if polynomial empty. make the node the head node if(head == NULL) { head = newNode ; } else // else go to the last node and append { temp = head; while(temp->next != NULL) temp = temp->next; temp->next = newNode ; } return head; }

void polyDisplay ( struct node* head) { struct node *temp=head; while(temp != NULL) { if(temp->co >= 0) printf ("+%d^%d", temp->co, temp->expo); else printf ("%d^%d", temp->co, temp->expo ); temp=temp->next; } printf ("\n"); }

Polynomial Addition