+ 6
What is the value of k after operation? int k = 5; k += k++ + ++k; why its output depends on compiler?
11 Answers
+ 9
firstly, k=5
++k , k=6
k++ + ++k, 6+6=12
k+=k++ + ++k, now k++ was activated it made k=7
So finally k = 7+12 = 19
+ 6
why sololearn rejected that by saying it produces different outputs on different compilers?
+ 5
Yes, you are right. It can be executed correctly.
+ 4
bro its high level question in C
or other lang.
+ 4
Sorry, but answer is 19
+ 4
"why sololearn rejected that by saying it produces different outputs on different compilers?"
Because in this expression you have only addition, so you can't determine priority used by each compiler?
+ 4
Sorry bro, you can check on any compiler this code
it will give you answer 19
+ 2
You, twisted mind Oo
+ 2
I don't think you encounter this each days, and it's easy to clarify the code to avoid problems, at least with parenthesis, if it isn't by divide your one-line instruction to multi-line ones :P
+ 2
K = 16, don't ask how? đđđ
0
Answer in bluej is 17
k=5+5+7=17