1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Can some one answer this question

Discussion in 'C' started by avinash_reddy, Apr 10, 2008.

  1. avinash_reddy

    avinash_reddy New Member

    hi friends can some one answer this question plz

    int x=2;
    int r= x-- * ++x + ++x;
    printf("x= %d, r= %d", x, r);

    and also for

    r= ++x + ++x * --x;

    and

    r= ++x + ++x * x--;

    can some explain how these expressions are eveluated
     
  2. shabbir

    shabbir Administrator Staff Member

    The answer can change from compilers to compilers and so see what is the output in your compiler and just try justifying it.
     
  3. tarek issa

    tarek issa New Member

    i understood ur question.
    there is a trick in doing x++ and ++x, for example:
    if doing this:
    ++x*2 first x multiplyese by 2, and then it (x) increases by 1.
    if doing this:
    x++*2 first x increases by 1, and then the multiply will be done.
     
  4. technosavvy

    technosavvy New Member

    trying googling sequence point and u will understand why it is an undefined behaviour
     

Share This Page