#include struct list { int pow,coef; struct list *next; }; typedef struct list node; typedef node *link; link head,pt1,pt2; void print_poly(link head) { printf("the input polynomial ---> f(X)="); pt1=head; while (pt1 != NULL) { if (pt1->pow != 0) printf("%2dX%2d",pt1->coef,pt1->pow); else printf("%2d",pt1->coef); pt1=pt1->next; if (pt1 != NULL) printf("+"); } printf("\n"); } link create() { int c,p; link head,pt2,pt1; head=NULL; while (1) { printf("give me coefficient and power ?"); scanf("%d %d",&c,&p); if ((c == 0) && (p == 0)) break; pt2=(link)malloc(sizeof(node)); pt2->next=NULL; if (head == NULL) pt1=head=pt2; else pt1=pt1->next=pt2; pt2->coef=c; pt2->pow=p; } return head; } link concate(link h1, link h2) { link ptr; ptr=h1; while (ptr->next != NULL) ptr=ptr->next; ptr->next=h2; return h1; } void main() { int c,p; link h1,h2; printf("give me the first polynomial -->"); h1=create(); print_poly(h1); printf("give me the second polynomial-->"); h2=create(); print_poly(h2); h1=concate(h1,h2); print_poly(h1); }