199k views
4 votes
3.

If the variable step is set to equal 5 and then the code reads step = step + 2, what will step now equal?
0
2
5
7

User Sashanna
by
4.0k points

2 Answers

5 votes

Answer:

It should be 7

Explanation: What about steps = steps + 1? What is the purpose of that line? Well, since it uses one equal sign, we know that it is assigning (and not checking). This statement is being used simply to increment (increase) the steps variable by 1. We are taking the value previously held in steps , adding 1, and then re-assigning that value to steps. So, if the steps variable previously held 43, we add 1 to make it 44 and store it back in steps . This kind of a statement is very helpful in keeping score in a game or counting the number of times something has happened.

User Rabusmar
by
4.8k points
1 vote

Answer:

7

Step-by-step explanation:

5 + 2 = 7

User Alex Fragotsis
by
4.1k points