This is my derivative function. This code works correctly but does not delete the constant term. It sets directly to 0 and writes to the result. how can i fix this? Thank you..
EX:
Input: "-x^3-6x^2+ 4x+22"
Output: “-3.0x^2 -12x +4.0 + 0.0”
How can i delete this 0.0?

struct PolyNode { 
    double coef;              
    int exp;                  
    struct PolyNode* next;    
}; 
/////////////////////////////////////// 
PolyNode* Derivative(PolyNode* poly) { 
    PolyNode* current = new PolyNode; 
    current = poly; 

    //Just goes through entire list 
    while (current != NULL) { 
        if (current->exp == 0) { 
            current->coef = 0; 
            current->exp = 0; 
            current = current->next; 
        } 
        else { 
            current->coef = current->coef * current->exp; 
            current->exp = current->exp - 1; 
            current = current->next; 
        } 
    } 


    return poly;

I see you crossposted but agree the question is missing input and corresponding output statements.

Thanks for your comment. So what do I have to do to fix these mistakes? I'm pretty new at data structures

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.