Chapter 3.6 – Multiple Assignment and Combined Assignment C++ – Flashcards

Unlock all answers in this set

Unlock answers
question
Given an integer variable bridgePlayers, write an statement that increases the value of that variable by 4.
answer
bridgePlayers += 4;
question
Given an integer variable profits, write a statement that increases the value of that variable by a factor of 10.
answer
profits *= 10;
question
Write a statement using a compound assignment operator to add 5 to val (an integer variable that has already been declared and initialized ).
answer
val += 5;
question
Write a statement using a compound assignment operator to subtract 10 from minutes_left (an integer variable that has already been declared and initialized ).
answer
minutes_left -= 10;
question
Write a statement using a compound assignment operator to cut the value of pay in half (pay is an integer variable that has already been declared and initialized ).
answer
pay /= 2;
question
Write a statement using a compound assignment operator to multiply num_rabbits by 4, changing the value of num_rabbits (num_rabbits has already been declared and initialized ).
answer
num_rabbits *= 4;
question
Write a statement using a compound assignment operator to change val to the remainder when val is divided by 16 (val has already been declared and initialized )
answer
val %= 16;
question
Write a statement using the increment operator to increase the value of num_items (an already declared integer variable ) by 1.
answer
num_items += 1;
question
Write a statement using the decrement operator to decrease the value of count (an already declared integer variable ) by 1.
answer
count -= 1;
Get an explanation on any task
Get unstuck with the help of our AI assistant in seconds
New