Could someone explain me the logic??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sarath88
    New Member
    • Aug 2010
    • 1

    Could someone explain me the logic??

    main()
    {
    int a;
    int k;
    a=1;

    for(k=0;k<10;k+ +)
    {
    printf("%d %d %d\n",++a,a++,+ +a);
    }
    }

    Output is:

    3 2 2
    6 5 5.....
  • newb16
    Contributor
    • Jul 2008
    • 687

    #2
    was asked yesterday and some more times before

    Comment

    • Oralloy
      Recognized Expert Contributor
      • Jun 2010
      • 988

      #3
      @Sarath88,

      The program ventures into the realm of undefined behaviour. It auto-increment and/or auto-decrement of the same memory multiple times within an expression.

      Comment

      Working...