edited by
1,149 views

2 Answers

1 votes
1 votes
Look at it this way
q=p++;
q=q + p++;

so the first time when p is encountered in this expression is treated as 1, the next ++ increments p by 1 so p becomes two. the second operand p is now treated as 2 so (1+2) becomes three. Now after that ++ is encountered which makes p=3. So this is why p becomes three and q becomes three
0 votes
0 votes
Step first- p=1 stored and then incremented

Step two- p=2 stored and then incremented to 3

Then q=1+2=3

And p has been incremented and and its value is 3...so final value stored in p is 3

Related questions

0 votes
0 votes
2 answers
2
Nikhil Patil asked Feb 16, 2018
2,458 views
Why not Output is showing 90? #include <stdio.h int main() { extern int p; printf("%d ", p); { int p = 90; printf("%d ", p); } }
2 votes
2 votes
1 answer
3
Rustam Ali asked Sep 2, 2016
927 views
Avoid the any syntax error ,if there is:What will be the output of the following code ? #inlcude<stdio.h void myfun(int i) { if(i>0) { myfun(i-1); printf("%d",i); myfun(i...
0 votes
0 votes
1 answer
4
Ujjaval251 asked Mar 14, 2023
981 views
S1 : An insertion in an AVL with n nodes requires O(n) rotations.answer is false in answer key,but is guess for 1 insetion its O(1).so for n it will be O(n).tell me if i ...