printing derivative

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jlynx23
    New Member
    • Jan 2008
    • 6

    printing derivative

    gud am...i am currently working with a project of mine which is about derivative...an d i am having some problem with the printing of the derivative...
    here is the block of code i used:

    /* print derivative of each term */

    x=30;
    gotoxy(x, 15);
    if(exponent!=0) {
    if(coefficient* exponent>=1){
    printf("%d",coe fficient*expone nt);
    x++;
    }

    if(exponent-1>=1){
    printf("%c",var iable);
    x++;
    if(exponent-1!=1){
    printf("%d",exp onent-1);
    x++;
    }
    }
    else if(exponent-1==0){
    printf("%c",ope rator[ctr]);
    x++;
    }
    }

    else{
    printf("0 %c ",operator[ctr]);
    x++;
    }
    }



    could someone help me why it always prints on the location coordinates (30, 15)? i would gladly and humbly accept any comments or suggetstions that would help me in this work...gud day...
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    It always prints at (30,15) because you use gotoxy(x,15) after you set x to 30. If you want it to print someplace else, change that initialization.

    Comment

    • jlynx23
      New Member
      • Jan 2008
      • 6

      #3
      Originally posted by Laharl
      It always prints at (30,15) because you use gotoxy(x,15) after you set x to 30. If you want it to print someplace else, change that initialization.

      uhm...i want to start printing the derivative at that cooridanate...h owever, the cursor is not moving even if i try to change the value of x by incrementing...
      can u pls tell me why it happened so?

      Comment

      • Laharl
        Recognized Expert Contributor
        • Sep 2007
        • 849

        #4
        You don't call gotoxy() again, so it doesn't know to move. Just because you passed x to gotoxy() doesn't mean every change in x will bring about another call to the function to reflect the update.

        Comment

        Working...