Declare a class name “Polynomial” which contains an array of size (n) (dynamic allocation of this array is not required, you can use a global variable to represent the degree of the polynomial, to store the coefficients of the polynomial into the indices corresponding to their powers. For example if we want to make a polynomial 2x4 + 3x3 – 12x2 + x – 19 (degree-4) then the polynomial class will have an array of the following form. –19, 1, -12, 3, 2
Polynomial (int degree)
Description: Constructor, which initializes the array to zero.
void outputPolynomial()
Description: Prints the polynomial in the following format, 2x^4 + 3x^3 – 12x^2 + x -19
I have written the following Code. But I am confused how to assign value to the polynomial in the main function. And how to initialize the global variable.