Your problem is that when you say
int car = car + 1;
Basically you create a local variable called car (local for the if statement), which is set to 51 (since the original local area variable (local to main) contains 50 and you add 1). This local variable (included in the if statement) is destroyed as soon as you exit the if statement.
If you change it to
car = car + 1;
Now you change the local variable to main, and therefore the update will be saved.
source share