edited by
1,000 views
0 votes
0 votes

Can someone explain why this is happening. I have found post increment has higher precedence than pre-increment . And Post increment is left associative and pre-increment is right associative.

For the 1st printf it it is 5,6

but the 2nd printf it is 6,7

Why in post increment both statemet has differenet value.

https://www.geeksforgeeks.org/c-operator-precedence-associativity/

edited by

Please log in or register to answer this question.

Related questions

5 votes
5 votes
2 answers
2
saurabh0709 asked Aug 1, 2023
1,250 views
What will be the output of the following code? _______ #include <stdio.h int main(){ char val=250; int ans; ans= val+ !val + ~val + ++val; printf("%d", ans); return 0; }
1 votes
1 votes
3 answers
3
Ram Swaroop asked Dec 18, 2018
422 views
Which operator has higher priority between *and / in any expression how to evaluate them
3 votes
3 votes
5 answers
4
arpit.bagri asked Aug 6, 2023
1,091 views
Why is the output of the below program 36? int main(){ int a = 1; int b = ++a * ++a * ++a; printf("%d", b ); ​​​​ return 0; }