answersLogoWhite

0

#include<iostream.h> #include<stdlib.h> #include<conio.h> struct poly { int coeff; int x; int y; int z; struct poly * next; }; class polynomial { private : poly *head; public: polynomial():head(NULL) { } void getdata(); void display(); void insert(poly *prv,poly *curr,poly *p); polynomial operator + (polynomial ); }; polynomial polynomial :: operator +(polynomial px2) { polynomial px; poly *t1,*t2,*t3,*last; t1 = head; t2 = px2.head; px.head = NULL; while(t1 != NULL && t2 != NULL) { t3 = new poly; t3->next = NULL; if(t1->x t2->z) { t3->coeff = t1->coeff + t2->coeff; t3->x = t1->x; t3->y = t1->y; t3->z = t1->z; t1 = t1->next; t2 = t2->next; } elseif(t1->x > t2->x) { t3->coeff = t1->coeff; t3->x = t1->x; t3->y = t1->y; t3->z = t1->z; t1 = t1->next; } elseif(t1->x < t2->x) { t3->coeff = t2->coeff; t3->x = t2->x; t3->y = t2->y; t3->z = t2->z; t2 = t2->next; } elseif(t1->y > t2->y) { t3->coeff = t1->coeff; t3->x = t1->x; t3->y = t1->y; t3->z = t1->z; t1 = t1->next; } elseif(t1->y < t2->y) { t3->coeff = t2->coeff; t3->x = t2->x; t3->y = t2->y; t3->z = t2->z; t2 = t2->next; } elseif(t1->z > t2->z) { t3->coeff = t1->coeff; t3->x = t1->x; t3->y = t1->y; t3->z = t1->z; t1 = t1->next; } elseif(t1->z < t2->z) { t3->coeff = t2->coeff; t3->x = t2->x; t3->y = t2->y; t3->z = t2->z; t2 = t2->next; } if(px.head == NULL) px.head = t3; else last->next = t3; last = t3; } if(t1 == NULL) t3->next = t2; else t3->next = t1; return px; } void polynomial :: insert(poly *prv,poly *curr,poly *node) { if(node->x curr->z) { curr->coeff += node->coeff; delete node; } elseif((node->x > curr->x) (node->x curr->y && node->z > curr->z)) { node->next = curr; prv->next = node; } else { prv = curr; curr = curr->next; if(curr == NULL) { prv->next = node; node->next = NULL; return; } insert(prv,curr,node); } return; } void polynomial :: getdata() { int tempcoeff; poly *node; while(1) { cout << endl << "Coefficient : "; cin >> tempcoeff; if (tempcoeff==0) break; node = new poly; node->coeff = tempcoeff; cout << endl << "Power of X : "; cin >> node->x; cout << endl << "Power of Y : "; cin >> node->y; cout << endl << "Power of Z : "; cin >> node->z; if(head == NULL) { node->next = NULL; head = node; } elseif(node->x head->z) { head->coeff += node->coeff; delete node; } elseif((node->x > head->x) (node->x head->y && node->z > head->z)) { node->next = head; head = node; } elseif (head->next == NULL) { head->next = node; node->next = NULL; } else insert(head,head->next,node); } } void polynomial :: display() { poly *temp; temp = head; cout << endl << "Polynomial :: "; while(temp != NULL) { if(temp->coeff < 0) cout << " - "; cout << abs(temp->coeff); if(temp->x != 0) cout << "x^" << temp->x; if(temp->y != 0) cout << "y^" << temp->y; if(temp->z != 0) cout << "z^" << temp->z; if(temp->next->coeff > 0) cout << " + "; temp = temp->next; } cout << " = 0"; } void main() { polynomial px1,px2,px3; clrscr(); px1.getdata(); px2.getdata(); px3 = px1 + px2; px1.display(); px2.display(); px3.display(); getch(); }

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Addition of polynomial?

addition of coefficient


What are some similarities between rational functions and polynomial function?

Rational functions and polynomial functions both involve expressions made up of variables raised to non-negative integer powers. They can have similar shapes and behaviors, particularly in their graphs, where they may exhibit similar end behavior as the degree of the polynomial increases. Additionally, both types of functions can be manipulated algebraically using addition, subtraction, multiplication, and division, although rational functions can include asymptotes due to division by zero, which polynomial functions do not have. Both functions can also be analyzed using techniques such as factoring and finding roots.


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

It is called the property of "closure".


Are polynomial expressions closed under addition?

Yes.


How different a polynomial to non polynomial in terms of?

Polynomials are algebraic expressions that consist of variables raised to non-negative integer powers, combined using addition, subtraction, and multiplication, such as ( ax^n + bx^{n-1} + \ldots + c ). In contrast, non-polynomial expressions can include variables raised to negative or fractional powers, exponential functions, logarithms, or trigonometric functions, such as ( e^x ) or ( \frac{1}{x} ). The defining characteristic of polynomials is their continuity and differentiability over the entire real line, while non-polynomials may have discontinuities or undefined points. This fundamental difference affects their behavior, solutions, and the types of equations they can represent.


What are the chips in polynomial damath?

In polynomial damath, the chips represent the individual terms of a polynomial expression. Each chip can be seen as a discrete unit that corresponds to a specific power of the variable, typically denoted by colors or sizes to indicate their coefficients and degrees. Players manipulate these chips to perform polynomial operations like addition, subtraction, or multiplication, making the abstract concepts of polynomials more tangible and interactive. The use of chips helps in visualizing and understanding polynomial relationships and operations effectively.


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.


Programfor addition of two polynomial using circular link list?

dsd


What is the rules of addition and subtraction in polynomials?

6+6=12 Boom polynomial


What two properties are commonly used when multiplying a monomial by a polynomial?

Distributive property of multiplication over addition, Commutativity of addition.


What is a numbera variableor a number and variable multiplied togetherseparated by addition and subtraction called?

A number and a variable multiplied together, separated by addition and subtraction, is called a polynomial. In a polynomial, the variables can have non-negative integer exponents, and the coefficients can be any real numbers. For example, (3x^2 + 4x - 5) is a polynomial.