How do I add polynomials and print them? [List]

Oct 16, 2016 at 11:21pm
a
Last edited on Oct 25, 2016 at 3:33am
Oct 21, 2016 at 3:33am
bump
Oct 21, 2016 at 8:20am
Your code seems to be vastly over-complicated. Fundamentally, a polynomial is defined by the set of its coefficients - so use arrays!
e.g. a[0] + a[1]x + a[2]x^2 + ... + a[N]x^N
The polynomial is defined by the array a[], of size N+1.

To 'add' two polynomials you are simply adding corresponding array elements and forming a new array.

To 'output' the polynomial, loop through the elements of the array, outputting a[i]x^i for i = 0 up to the degree N of the polynomial.

I haven't a clue why you are using a pointer polyPtr (and have no idea where it is defined).


Oct 21, 2016 at 1:10pm
Not enough information.
You need to show your declarations for PolyType and TermNode.

Topic archived. No new replies allowed.