Ask Question

Which of the following is NOT a valid method to increase a variable named score by 1?

a.

++score = score + 1

b.

score = score + 1

c.

score++

d.

++score

+5
Answers (1)
  1. 7 July, 19:18
    0
    a.

    ++score = score + 1

    Explanation:

    First you have to understand the increment operator;

    There are three possible ways to increment the value of variable by 1.

    1. post increment

    syntax:

    name++

    it using in expression first then increase the value by 1.

    2. Pre increment

    syntax:

    ++name

    it increase the value by 1 before it using in expression.

    3. simple method

    name = name + 1

    In the question,

    option 1: + +score = score + 1

    it increase the value of score by 2 because their are two increment is used first for (score + 1) and second + +score.

    Therefore, the correct option is a.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Which of the following is NOT a valid method to increase a variable named score by 1? a. ++score = score + 1 b. score = score + 1 c. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers