Question: Study the following code, and then answer Questions 1 4. .Remember that number2 += number1; is the same as number2 = number2 + number1; .
Study the
following code, and then answer Questions 1 4. .Remember that number2 += number1; is the same as number2 = number2 + number1; .
int number1 = 0;
int number2 = 0;
while(number1 < 6)
number1++;
number2 += number1;
1. What is the value of number1 when the loop exits?
2. What is the value of number2 when the loop exits?
3. If the statement number1++ is changed to ++number1 , what is the value of number1 when the loop exits?
4. What could you do to force the value of number2 to be 21 when the loop exits?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
