Ploynomial addition
-
Upload
raviahuja11 -
Category
Education
-
view
187 -
download
0
description
Transcript of Ploynomial addition
![Page 1: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/1.jpg)
Polynomial Addition
#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<alloc.h>
void CreatePolyFirst();
void CreatePolySecond(); //Function Protypes
void AddPoly();
void Attach(int, int, struct node *);
struct node
{
int coef , exp; //Structure Definition
struct node *next;
} *first=NULL, *second=NULL, *New=NULL, *temp1=NULL,
*temp2=NULL, *result=NULL, *temp3=NULL;
![Page 2: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/2.jpg)
Polynomial Addition
void main()
{
int ch;
clrscr();
do
{
printf("\n***MENU***");
printf("\n1.Create 1st Polynomial”);
printf(“\n2.Create 2nd Polynomial”);
printf("\n3.Add Both Polynomial
printf(”\n4.Exit");
printf("\nPlease Enter the Choice...");
scanf("%d",&ch);
![Page 3: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/3.jpg)
Polynomial Addition
switch(ch)
{
case 1: CreatePolyFirst();
break;
case 2: CreatePolySecond();
break;
case 3: AddPoly();
break;
case 4: exit(0);
default: printf("\n Invalid Choice...");
}
}while(ch!=4);
getch();
}
![Page 4: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/4.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
New
first = NULL
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
\
![Page 5: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/5.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef); 5
if(New->coef==0)
break;
New
first = NULL
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 \
![Page 6: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/6.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
New
first = NULL
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 \
![Page 7: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/7.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
New
first = NULL
printf("\nEnter the Exponent...");
scanf("%d",&New->exp); 2
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \
![Page 8: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/8.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
New
first = NULL
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \
![Page 9: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/9.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
New, first
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \
![Page 10: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/10.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
New,first
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \
![Page 11: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/11.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
New,first
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \
![Page 12: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/12.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first New
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \ \
![Page 13: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/13.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef); 8
if(New->coef==0)
break;
first New
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \ 8 \
![Page 14: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/14.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first New
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \ 8 \
![Page 15: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/15.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first New
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp); 1
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \ 8 1 \
![Page 16: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/16.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first New
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 \ 8 1 \
![Page 17: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/17.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first New
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 8 1 \
![Page 18: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/18.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first New
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 8 1 \
![Page 19: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/19.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first New
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 8 1 \
![Page 20: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/20.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
New 5 2 8 1 \ \
![Page 21: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/21.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef); 4
if(New->coef==0)
break;
first
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
New 5 2 8 1 \ 4 \
![Page 22: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/22.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
New 5 2 8 1 \ 4 \
![Page 23: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/23.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp); 0
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
New 5 2 8 1 \ 4 0 \
![Page 24: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/24.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
New 5 2 8 1 \ 4 0 \
![Page 25: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/25.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first
temp1
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
New 5 2 8 1 4 0 \
![Page 26: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/26.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
New
temp1
5 2 8 1 4 0 \
![Page 27: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/27.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
New
temp1
5 2 8 1 4 0 \
![Page 28: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/28.jpg)
void CreatePolyFirst()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
first
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(first==NULL)
{
first=New;
temp1=New;
}
else
{
temp1->next=New;
temp1=New;
}
if(New->exp==0)
break;
}}
5 2 8 1 4 0 \
![Page 29: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/29.jpg)
void CreatePolySecond()
{
printf("\nEnter Polynomial in Descending Order...\n");
printf("\nFor end enter 0.\n");
while(1)
{
New=(struct node *) malloc (sizeof (struct node));
New->next=NULL;
printf("\nEnter the Coefficient...");
scanf("%d",&New->coef);
if(New->coef==0)
break;
second
printf("\nEnter the Exponent...");
scanf("%d",&New->exp);
if(Second==NULL)
{
second=New;
temp2=New;
}
else
{
temp2->next=New;
temp2=New;
}
if(New->exp==0)
break;
}}
4 4 7 2 2 1 \
![Page 30: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/30.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL) .
{
New=(struct node *) malloc (sizeof (struct node));
first
second
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
![Page 31: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/31.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
q
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
![Page 32: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/32.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL) .
{
New=(struct node *) malloc (sizeof (struct node));
first p second
q
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
![Page 33: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/33.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
qNew
New->next=NULL;
if(p->exp==q->exp) 2==4
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
\
![Page 34: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/34.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
qNew
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp) 2<4
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
\
![Page 35: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/35.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
qNew
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
\
![Page 36: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/36.jpg)
void Attach(int c,int e,struct node *d) .
{ (4, 4, New)
if(result==NULL)
{
result=d;
temp3=New;
temp3->coef=c;
temp3->exp=e;
}
first p second
qNew
else
{
temp3->next=d;
temp3=d;
temp3->coef=c;
temp3->exp=e;
}
}
result= NULL
4 4 7 2 2 1 \
5 2 8 1 4 0 \
\
![Page 37: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/37.jpg)
void Attach(int c,int e,struct node *d) .
{ (4, 4, New)
if(result==NULL)
{
result=d;
temp3=New;
temp3->coef=c;
temp3->exp=e;
}
first p second
qNew result, temp3
else
{
temp3->next=d;
temp3=d;
temp3->coef=c;
temp3->exp=e;
}
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
\
![Page 38: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/38.jpg)
void Attach(int c,int e,struct node *d) .
{ (4, 4, New)
if(result==NULL)
{
result=d;
temp3=New;
temp3->coef=c;
temp3->exp=e;
}
first p second
qNew result, temp3
else
{
temp3->next=d;
temp3=d;
temp3->coef=c;
temp3->exp=e;
}
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 \
![Page 39: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/39.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
qres,
temp3
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 \
![Page 40: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/40.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
q res, New temp3
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 \ \
![Page 41: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/41.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
q res, New temp3
New->next=NULL;
if(p->exp==q->exp) 2==2
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 \ \
![Page 42: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/42.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
q res, New temp3
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef; x= 5+7=12
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 \ \
![Page 43: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/43.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first p second
q res, temp3
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 \
![Page 44: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/44.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first psecond
res, temp3
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
q
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 \
![Page 45: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/45.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first psecond
res
temp3
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
q
New
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 \ \
![Page 46: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/46.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first psecond
res
temp3
New->next=NULL;
if(p->exp==q->exp) 1==1
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
q
New
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 \ \
![Page 47: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/47.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first psecond
res
temp3
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef; x=8+2=10
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
q
New
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 \ \
![Page 48: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/48.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first psecond
res
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
q
temp3
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 10 1 \
![Page 49: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/49.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first
second
res
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
p
q=NULL
temp3
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 10 1 \
![Page 50: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/50.jpg)
void AddPoly()
{
struct node *p,*q,*r; int x;
if(first==NULL || second==NULL)
{
printf("\nYour First or Second Polynomial is Invalid...");
return;
}
p=first; q=second;
while(p!=NULL && q!=NULL)
{
New=(struct node *) malloc (sizeof (struct node));
first
second
res
New->next=NULL;
if(p->exp==q->exp)
{
x=p->coef+q->coef;
if(x!=0)
Attach(x,p->exp,New);
p=p->next;
q=q->next;
}
else if(p->exp<q->exp)
{
Attach(q->coef,q->exp,New);
q=q->next;
}
p
q=NULL
temp3
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 10 1 \
![Page 51: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/51.jpg)
else
{
Attach(p->coef, p->exp, New);
p=p->next;
}}
while(p!=NULL)
{
Attach(p->coef,p->exp,p);
p=p->next;}
while(q!=NULL)
{
Attach(p->coef,p->exp,q);
q=q->next;}
first
second
res
printf("\nAddition of Both Polynomial...\n");
if(result==NULL)
{
printf("0"); return;
}
while(result!=NULL)
{
printf("%dx^%d",New->coef,New->exp);
if(result->next!=NULL)
printf(" + ");
New=New->next;
}
}
p
q=NULL
temp3
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 10 1 \
![Page 52: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/52.jpg)
else
{
Attach(p->coef, p->exp, New);
p=p->next;
}}
while(p!=NULL)
{
Attach(p->coef,p->exp,p);
p=p->next;}
while(q!=NULL)
{
Attach(p->coef,p->exp,q);
q=q->next;}
first
second
res
printf("\nAddition of Both Polynomial...\n");
if(result==NULL)
{
printf("0"); return;
}
while(result!=NULL)
{
printf("%dx^%d",New->coef,New->exp);
if(result->next!=NULL)
printf(" + ");
New=New->next;
}
}
p=NULL
q=NULL
temp3
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 10 1 4 0 \
![Page 53: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/53.jpg)
else
{
Attach(p->coef, p->exp, New);
p=p->next;
}}
while(p!=NULL)
{
Attach(p->coef,p->exp,p);
p=p->next;}
while(q!=NULL)
{
Attach(p->coef,p->exp,q);
q=q->next;}
first
second
res
printf("\nAddition of Both Polynomial...\n");
if(result==NULL)
{
printf("0"); return;
}
while(result!=NULL)
{
printf("%dx^%d",New->coef,New->exp);
if(result->next!=NULL)
printf(" + ");
New=New->next;
}
}
p=NULL
q=NULL
4 4 7 2 2 1 \
5 2 8 1 4 0 \
4 4 12 2 10 1 4 0 \
![Page 54: Ploynomial addition](https://reader033.fdocuments.net/reader033/viewer/2022061220/54ba79944a7959c2498b4578/html5/thumbnails/54.jpg)
else
{
Attach(p->coef, p->exp, New);
p=p->next;
}}
while(p!=NULL)
{
Attach(p->coef,p->exp,p);
p=p->next;}
while(q!=NULL)
{
Attach(p->coef,p->exp,q);
q=q->next;}
res
res - > 4x^4 + 12x^2 + 10x^1 + 4
printf("\nAddition of Both Polynomial\n");
if(result==NULL)
{
printf("0"); return;
}
while(result!=NULL)
{
printf("%dx^%d",New->coef,New->exp);
if(result->next!=NULL)
printf(" + ");
New=New->next;
}
}
4 4 12 2 10 1 4 0 \