Which statement has the same effect as 'count = count + 2'?

Enhance your programming skills with the RECF Programming Test. Features flashcards and multiple choice questions with hints and explanations. Prepare for success!

Multiple Choice

Which statement has the same effect as 'count = count + 2'?

Explanation:
The main idea is updating a variable by increasing its current value with a shorthand operation. count = count + 2 and count += 2 do the same thing: take the current value of count, add 2, and store the result back in count. The plus-equals form is just a shorter way to write that exact update. The other expressions either add a different amount or multiply, so they don't produce the same result.

The main idea is updating a variable by increasing its current value with a shorthand operation. count = count + 2 and count += 2 do the same thing: take the current value of count, add 2, and store the result back in count. The plus-equals form is just a shorter way to write that exact update. The other expressions either add a different amount or multiply, so they don't produce the same result.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy