user23577853
user23577853

Reputation:

I don't understand how the final values of 2 variables are calculated after an addition of a pre-increment and post-increment

#include <stdio.h>

int main()
{
    int i = 0;
    int j = 0;
    j = i++ + ++i;
    printf("%d %d", i, j);
return 0;
}

After compilation and run, the output is i = 2 and j = 2

I don't understand how the final values of i and j are calculated

I just want to understand about precedence and associativity in this specific example of code

Upvotes: 0

Views: 32

Answers (0)

Related Questions