Yes because you didn't use pre increment or post increment. You have just added 2 with a but actually it will not add 2 in a. It will just check condition so a is remain same here but if you print a + 2 then output will be different.
No it will not override it will increment by 1 as you used a++
According to your condition a++ < b is false because 5 < 4 is false so it will go in else part but remember there is Post increment a++ so after checking condition a will be 6.
That's why you got output 6. This was your doubt. Am I right?
🅰🅹 (Challenge Accepted) yep kind of it I understand but if I do increment then the value of a change but if I try any other value then the value of remains unchanged like
why it is changed in increments and unchanged in other value?
See a++ is post increment which first assign value then increment by 1
But a + 2 is not a post increment. Here you are just adding 2 in a but remember a will be remain same
For example : a = 10
So if you print a + 2 then output will be 12 but if you just print a then output will be 10.
It is post increment so, it first compare and then increment the value.
a++ < b is 5<4 which is false
Then it will immediately go to else block
In else block it will print the incremented value of a i.e, 6