answersLogoWhite

0

POLYNOMIAL ADDITION

#include

#include

typedef struct poly

{

int coeff;

int expo;

}p;

p p1[10],p2[10],p3[10];

void main()

{

int t1,t2,t3,k;

int read(p p1[10]);

int add(p p1[10],p p2[10],int t1,int t2,p p3[10]);

void print(p p2[10],int t2);

void printo(p pp[10],int t2);

clrscr();

t1=read(p1);

print(p1,t1);

t2=read(p2);

print(p2,t2);

t3=add(p1,p2,t1,t2,p3);

printo(p3,t3);

getch();

}

int read(p p[10])

{

int t1,i;

printf("\n Enter the total no of terms");

scanf("%d",&t1);

printf("\n Enter the coeff and expo in descending order");

for(i=0;i

scanf("%d%d",&p[i].coeff,&p[i].expo);

return(t1);

}

int add(p p1[10],p p2[10],int t1,int t2,p p3[10])

{

int i,j,k;

int t3;

i=0,j=0,k=0;

while(i

{

if(p1[i].expo==p2[j].expo)

{

p3[k].coeff=p1[i].coeff+p2[j].coeff;

p3[k].expo=p1[i].expo;

i++;j++;k++;

}

else if(p1[1].expo>p2[j].expo)

{

p3[k].coeff=p1[i].coeff;

p3[k].expo=p1[i].expo;

i++;k++;

}

else

{

p3[k].coeff=p2[j].coeff;

p3[k].expo=p2[j].expo;

j++;k++;

}

}

while(i

{

p3[k].coeff=p1[i].coeff;

p3[k].expo=p1[i].expo;

i++;k++;

}

while(j

{

p3[k].coeff=p2[j].coeff;

p3[k].expo=p2[j].expo;

j++;k++;

}

t3=k;

return(t3);

}

void print(p pp[10],int term)

{

int k;

printf("\n\n Given Polynomial:");

for(k=0;k

printf("%dx^%d+",pp[k].coeff,pp[k].expo);

printf("%dx^%d",pp[k].coeff,pp[k].expo);

}

void printo(p pp[10],int term)

{

int k;

printf("\n\n The addition of polynomial:");

for(k=0;k

printf("%dx^%d+",pp[k].coeff,pp[k].expo);

printf("%dx^%d",pp[k].coeff,pp[k].expo);

}

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Write a c program add two polynomial using link list?

GOUDHMARINI


Addition of polynomial?

addition of coefficient


Which property of polynomial addition says that the sum of two polynomials is always a polynomial?

It is called the property of "closure".


Write a c program for matrix addition using function?

#include<


How do you write a C plus plus program which involves polynomial addition and subtraction?

Polynomial addition and subtraction is a relatively straightforward process. You add or subtract coefficients of like order. This is a perfect example of a linked list, where the head of the list is order 0, the next element is order 1, and so on and so forth. Each element only needs one data item - the numeric coefficient. In C, you could do this as an ordinary linked list, or as an array, perhaps of dynamic size. In C++, you could create a polynomial class with operators to add and subtract, leaving the implementation details inside - it would no longer matter if it were a linked list, a dynamic array, or whatever. That is the beauty of encapsulation.


C Matrix addition program?

How we can addition Two Matrix plz send coding in C language mahesh dhanotiya astah_mahesh@rediff.com how i can built a square matrix in c,


Are polynomial expressions closed under addition?

Yes.


Why might it be useful to know the linear factors of a polynomial function?

It is useful to know the linear factors of a polynomial because they give you the zeros of the polynomial. If (x-c) is one of the linear factors of a polynomial, then p(c)=0. Here the notation p(x) is used to denoted a polynomial function at p(c) means the value of that function when evaluated at c. Conversely, if d is a zero of the polynomial, then (x-d) is a factor.


What is polynomial division?

That means that you divide one polynomial by another polynomial. Basically, if you have polynomials "A" and "B", you look for a polynomial "C" and a remainder "R", such that: B x C + R = A ... such that the remainder has a lower degree than polynomial "B", the polynomial by which you are dividing. For example, if you divide by a polynomial of degree 3, the remainder must be of degree 2 or less.


What does it mean for a polynomial to be closed under addition subtraction and multiplication?

It means that you can do any of those operations, and again get a number from the set - in this case, a polynomial. Note that if you divide a polynomial by another polynomial, you will NOT always get a polynomial, so the set of polynomials is not closed under division.


If polynomial is not any number then how will you define a polynomial?

An expression made with constants, variables and exponents, which are combined using addition, subtraction and multiplication, ... but not division.


To find the factors of a polynomial from its graph follow this rule If the number is a root of a polynomial then x - c is a factor?

a