154k views
4 votes
Which of the following will NOT correctly increment the value by one of a previously initialized integer variable named counter?

counter + 1;

counter++;

counter = counter + 1;

counter += 1;

All of the above will correctly increment the value by one.

1 Answer

2 votes

counter + 1; will raise the value by one but it will not set the value of counter to itself + 1, therefore,

counter + 1; is the correct answer

User Aderuwe
by
5.9k points