Study Compound Assignment Operators in AP Computer Science a with focused flashcards that help you recognize the idea, recall the key rule, and apply it in practice-style prompts.
All flashcards
Flashcard 1: What is the result after 'z *= 3' if z is 7?
Answer:
- 7 × 3 = 21, then assigned back to z.
Flashcard 2: What does 'x -= y' do to x?
Answer: Decreases x by y. Equivalent to x = x - y.
Flashcard 3: What does 'x += y' do to x?
Answer: Increases x by y. Equivalent to x = x + y.
Flashcard 4: Which operator performs division and assignment?
Answer: /=. Combines division (/) with assignment (=).
Flashcard 5: What operation does 'x %= 5' perform?
Answer: Assigns remainder of x divided by 5. Uses modulo operator to find remainder.
Flashcard 6: What does the operator '+=' do?
Answer: Adds right operand to left and assigns the result. Equivalent to x = x + (right operand).
Flashcard 7: Which operator is used for addition and assignment?
Answer: +=. Combines addition (+) with assignment (=).
Flashcard 8: What is the result of 'y /= 2' if y is 9?
Answer: 4.5. 9 ÷ 2 = 4.5, then assigned back to y.
Flashcard 9: What is the result of 'x *= 3' if x is initially 2?
Answer:
- 2 × 3 = 6, then assigned back to x.
Flashcard 10: Identify the compound assignment operator in 'x += 5'.
Answer: +=. The += operator is clearly visible in the expression.
Flashcard 11: What does the operator '*=' in 'x *= y' do?
Answer: Multiplies x by y and assigns. Equivalent to x = x * y.
Flashcard 12: What does '/=' do in terms of operation?
Answer: Divides left operand by right and assigns. Equivalent to x = x / (right operand).
Flashcard 13: Which operator is used for addition and assignment?
Answer: +=. Combines addition (+) with assignment (=).
Flashcard 14: Which operator performs division and assignment?
Answer: $/=Combinesdivision($/) with assignment (=).
Flashcard 15: What does the operator '*=' in 'x *= y' do?
Answer: Multiplies x by y and assigns. Equivalent to x = x * y.
Flashcard 16: What does '/=' do in terms of operation?
Answer: Divides left operand by right and assigns. Equivalent to x = x / (right operand).
Flashcard 17: What operation does 'x %= 5' perform?
Answer: Assigns remainder of x divided by 5. Uses modulo operator to find remainder.
Flashcard 18: What does 'x += y' do to x?
Answer: Increases x by y. Equivalent to x = x + y.
Flashcard 19: Which compound assignment operator multiplies and assigns?
Answer: =. Combines multiplication () with assignment (=).
Flashcard 20: State the operation for '-=' in code.
Answer: Subtracts right operand from left and assigns. Equivalent to x = x - (right operand).
Flashcard 21: What result does 'x %= 4' give if x is 9?
Answer:
- 9 mod 4 = 1, then assigned back to x.
Flashcard 22: Find the result: 'x %= 3' when x is 10.
Answer:
- 10 mod 3 = 1, then assigned back to x.
Flashcard 23: Identify the compound assignment operator in 'x += 5'.
Answer: +=. The += operator is clearly visible in the expression.
Flashcard 24: What result does 'x %= 4' give if x is 9?
Answer:
- 9 mod 4 = 1, then assigned back to x.
Flashcard 25: State the operation for '-=' in code.
Answer: Subtracts right operand from left and assigns. Equivalent to x = x - (right operand).
Flashcard 26: What is the result of 'x *= 3' if x is initially 2?
Answer:
- 2 × 3 = 6, then assigned back to x.
Flashcard 27: What is the result after 'z *= 3' if z is 7?
Answer:
- 7 × 3 = 21, then assigned back to z.
Flashcard 28: Which compound assignment operator multiplies and assigns?
Answer: =. Combines multiplication () with assignment (=).
Flashcard 29: Find the result: 'x %= 3' when x is 10.
Answer:
- 10 mod 3 = 1, then assigned back to x.
Flashcard 30: What is the result of 'y /= 2' if y is 9?
Answer: 4.5. 9 ÷ 2 = 4.5, then assigned back to y.
Flashcard 31: What does the operator '+=' do?
Answer: Adds right operand to left and assigns the result. Equivalent to x = x + (right operand).
Flashcard 32: What does 'x -= y' do to x?
Answer: Decreases x by y. Equivalent to x = x - y.