- include<stdio.h>
main()
{
int b=5;
int c= (b++) + (++b) + (++b) + (++b);
printf("%d",c);
}
Ans: The answer will be 29.
because
1st the value of b is 5
so in 1st b++ it will be 5(then will increment to 6)
so in 2nd ++b it will increment(b=6) value to 7.
and in 3rd ++b it will be 8
and in 4th ++b it will be 9
thus the final answer is 5+7+8+9=29...
-----
Although the above answer is correct but the approach is wrong i guess:
If you proceed according to your solution:
what will be the output for this:
x=5
y=++x * ++x;
printf("x=%d and y=%d",x,y);
?
Regards.