c++ adding 2 polynomials

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • beck2
    New Member
    • Jan 2007
    • 2

    c++ adding 2 polynomials

    hello i am angela and i would like if its kind of anyone to help me by writing me the code of adding 2 oplynomials?

    polynomials should be entered as [3x4+5x3+X] where 3,5 and 1 are coefficients of X to the power 4,X to the power 3 and X to the power of one.

    mostly appreciated
  • vpawizard
    New Member
    • Nov 2006
    • 66

    #2
    Hello,
    Following is the psuedo-code:

    int coef1[10];
    int coef2[10];

    The index denotes coefficient of power n. e.g.3x2+2x1+1 will stored in array as:
    coef1[2]=3;coef1[1]=2;coef1[0]=1;
    Similarly for second polynomial.
    Then, corresponding element in each array is added to get the addition of two polynomials.



    Regards,

    Comment

    Working...