1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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,285
    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