Question: A common way to represent a polynomial expression (e.g. 3x - 2.2x3 +4x - 1.713) is wth linked structures that have three members: A member

 A common way to represent a polynomial expression (e.g. 3x -

A common way to represent a polynomial expression (e.g. 3x - 2.2x3 +4x - 1.713) is wth linked structures that have three members: A member to represent the coefficient (3) a) b) A member to represent the exponent (5) c) A pointer to the next term in the expression Write a program that does the following: 1) Write a function input poly(ptr) that reads in two polynomials at a time with coefficient and exponent from a file cp in.tt. The file will contain 2n polynomials, where n is an integer that is 10 or less. Space for the polvnomial will be allocated in run time and there is no limit to the size of the polynomial, e..g the first two lines of the file is 35-2.2 3 41-1.713 0 3 100-2.2 3 14 55 3.1 101 Note the terms may be in any order) Then, two polynomials will be created 3x5 2.2x34x 1.713 and 3.1x3x10+ 14x 2.2x 2) Write a function add poly(ptr, ptr2) that expects pointers ptrl and ptr2 to two lists that represent 3) Write a function mult poly(ptrl, ptr2) that expects pointers ptr and ptr2 to two lists that represent 4) Write a function print poly(ptthat prints the polynomial pointed to by ptrl to a file, cp7.out. The terms From the function main), you may call the function print poly(ptr) to print out the following to cp7.out: polynomials and returns a pointer to a third list that represents the sum of polynomials. You will find the sum of every pair of polynomials. polynomials and returns a pointer to a third list that represents the product of polynomials. You will find the product of every pair of polynomials must be printed in descending order of exponent. That is to say, e.g. 3x5 2.2x3 +4x 1.713 is correct but e.g.-2.2x3x+4x 1.713 is not. The sum of polynomials 3x5 2.2x4x 1.713 3.13x14x.2x3 3.1x3x100 + 14x3x3- 4.4x3 4x-1.713 The product of polynomials 3x5 2.2x3 4x 1.713 3.1x3x100+ 14x2.x is 9.3x106 +9x105-6.82x104-6.6x10, 12.4x10, 6.6897x101-5. 139x100, 42,00-30.8x58 103?10 102 100 60 56x56 -23.982.55-6.686.8x4+3.7686x3 Precision up to 3 digits after the decimal is enough. Do not need more and do not print more (I have here, but you should not). Note that each polynomial can have any number of terms (which is why you will require malloc/calloc) but the total number of polynomials in the file will be 2n. There will be n pairs of polynomials. n is 10 pairs or less (i.e. 20 polynomials maximum)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!