
* powers in standard form where zero terms, coefficients 1 or -1, ** * Gives a string representation of this polynomial in descending In addition to the main, your program should consist of the following functions: As was the case with your previous project, use an sstream object when writing the polyToStr function that returns a string representation of a polynomial. Some function will return dynamically allocated arrays. This program will involve the implementation of several functions that use arrays as formal parameters. Write a program called PolyManipulator that uses a modular design. For now, this is enough to get us through the project. There is a lot more to dynamic memory allocation.

Memory leak is the allocation of a chunk of memory that contains inaccessible data and cannot be reallocated. When a variable associated with a dynamically allocated array is re-used, be sure to deallocate the array before using the variable. Proceed with caution when working with dynamically allocated arrays. It has to be reallocated if there is a need to re-use it. When an array is deallocated, it is no longer accessible. This example shows how the salaries array can be deallocated. To deallocate a dynamically allocated array, use the following syntax:

The example above creates an array of doubles that has the size of 10. Unlike static arrays that are deallocated when the function in which they are declared is terminated, dynamically allocated arrays are fully within the programmer’s control and may be deallocated at any point after they are created. double* salaries = new double ĭynamically allocating an array gives a programmer the ?exibility of being able to create an array of any size during run-time and deallocating the array when it is no longer needed. To dyanically allocate an array, the following syntax may be used:ĪrrayType* arrayName = new arrayType Įxample 1. In order to e?ectively manage memory, the array representing the polynomial entered by the user will be dynamically allocated.

The program will have functions generate a string representation of a polynomial in standard form, compute the indefinite integral of a polynomial, compute the derivative of a polynomial and evaluate a polynomial. In this project you will write an interactive program that represents univariate polynomials using arrays in which the coe?cients are arranged in order of descending powers.
