+ 2
Can anyone please tell me how the value of counter remains the same as 1?
4 Answers
+ 2
Hoping you have your correct code about your task...
You're welcome..
+ 2
count = count++;
It's post increment,
It will be evaluated as
first current count values used in instruction,
then count incremented by one and stored in count.
Next instruction result is back stored in lvalue that is again count. Here it replacing instruction result with post increment. So due to override, it's lost in increment so value remains same..
If you use any other variable as lvalue, you can retain count increment value..
counter = count++; so bath have different values...
Hope it helps...
+ 2
Thank you so much Jayakrishnađđ» again you're the one who helped me clarify my doubts
+ 2
U have written count =count++...
But it should either be count = count+1.... Or only count++