Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why... Why... Pls Tell me Why...

0 votes
asked Dec 20, 2018 by Simon Luk (120 points)

int main()
{
    int a = 1;
    int b = 1;
    int c = 1;
    int d = 1;
    
    a = a++ + a++;
    b = b++ + ++b;
    c = ++c + c++;
    d = ++d + ++d;
    
    printf("Result is: a=%d, b=%d, c=%d, d=%d", a, b, c, d);

    return 0;
}

Result is: a=3, b=4, c=5, d=6  

1 Answer

0 votes
answered Dec 20, 2018 by SS
Firstly, I recommend not to invest your time on pre and post increment operators, trust me if you do this in a real time project, code reviewers will definitely come back hard at you. If you think you might get this question in an interview, you can simply say I don't know and most probably interviewer will give a wrong answer too(happened to me)

Coming to the answer,

Check this link: https://gynvael.coldwind.pl/?id=372
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...