0
What is output of the đ code
Give answer in detail how it comes If you like code upvote me https://code.sololearn.com/c7QWOPAmVgJP/?ref=app
7 Answers
+ 2
You're welcome,
And it is good question BTW
Stay curious đ
0
It becomes easier to read and understand if you put spaces in between
printf("%d \n", a++ + b);
`a++` is post-increment operation, meaning it does not take effect immediately, until statement end (semicolon), or another post/pre increment is applied to variable <a>.
But mixing up access and modification to a certain data in one statement is not such good idea.
0
But it canbe like : a + ++b
How can you say it must be like
a++ + b
0
Excuse me, when did I say it *must be* like `a++ + b`?
You will get different result if you write `a + ++b` because this way pre-increment operator is applied on variable <b>.
The way your code was written (`a+++b`) compiler will take it as `a++ + b` because operator precedence plays a role there
https://en.cppreference.com/w/c/language/operator_precedence
0
Sorry for this
But when try to compile it always give answer 7
So my question is that why compiler read it as a++ + b why not a + ++b
0
It's because post-increment operator has higher precedence (priority) opposed to pre-increment operator. Read the linked page to see clearly.
0
Ok thank you