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,375
    Likes Received:
    388
    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:
    736
    Likes Received:
    39
    Trophy Points:
    28
    I could never get past this operators.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice