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

Pre and Post Increment/Decrement Operator

Discussion in 'C' started by shabbir, Jul 19, 2005.

  1. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Can anyone explain the output of the following program

    Code:
    int main()
    {
    
      int i=1;
      i = i++ + ++i + ++i + i++ + ++i;
      printf("%d\n",i);
    
      i=1;
      i = i-- - --i - --i - i-- - --i;
      printf("%d\n",i);
      return 0;
    }
    Output
    16
    2

    Thanks
    Shabbir Bhimani
     
  2. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    734
    Likes Received:
    37
    Trophy Points:
    0
    I could never get past this operators.
     

Share This Page