Hi,

I have to write a program that creates a polynomial with n coefficients and performs different operations. eg. 3x^2 + 5x + 1.
This may be defined as poly P(3) i.e p is a 3rd order polynomial.
the coefficients may be set as double Coef[3] = {3, 5 , 1} or P.set(coef);

I know that you do not give help unless i have written a code. but i don't have a code as i do not know how to set the coefficients in that particular way. I know how to handle the operations on the polynomials such as addition and subtraction. However, i just don't know how to set the coefficients as i described above. Please show me how to do this. Please help me. Please.
Thanks in advance for your help.

The prototype for the method should look like this: void Polynomial::set( const double coefficients[], unsigned count ); This takes an array of "count" coefficients.

Does this help? (If not, what is the type of coef in P.set(coef); ?)

The prototype for the method should look like this: void Polynomial::set( const double coefficients[], unsigned count ); This takes an array of "count" coefficients.

Does this help? (If not, what is the type of coef in P.set(coef); ?)

thank you very much for replying. coefficient is of integer type. Therefore, p(x) = 2x+2 should be represented as p.set(0, 2); p.set(1, 2);
I don't think that i mentioned that the polynomials are to be created using a linked list.

If that is right. I could be wrong. Perhaps the set() method is only supposed to set the degree of the polynomial? void Polynomial::set( int degree ); I don't know the details of your homework assignment.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.