Professional Documents
Culture Documents
Polynomial. C
Polynomial. C
h>
#include<conio.h>
struct node
{
int c;
int p;
struct node *link;
}*h1,*h2,*h3;
}
}
void append(int c,int p)
{
struct node *temp;
struct node *cur;
temp=(struct node *)malloc(sizeof(struct node));
temp->c=c;
temp->p=p;
cur=h3;
while(cur->link!=NULL)
{
cur=cur->link;
}
cur->link=temp;
temp->link=NULL;
}
void main()
{
clrscr();
h1=(struct node*)malloc(sizeof(struct node));
h2=(struct node*)malloc(sizeof(struct node));
h3=(struct node*)malloc(sizeof(struct node));
h1->link=NULL;
h2->link=NULL;
h3->link=NULL;
printf("enter the first polynomial\n");
add_rear(h1);
printf("enter the second polynomial\n");
add_rear(h2);
printf("the first polynomial is\n:");
display(h1);
printf("\nthe second polynomial is\n:");
display(h2);
add(h1,h2);
printf("the sum of polynomials:\n");
display(h3);
getch();
}