kallengmarium kallengmarium
  • 08-01-2017
  • Computers and Technology
contestada

Given the following code:

int i = 100;
int j = 10;
while (i > 0)
{
i = i / j;
j = 1 + j % 5;
}
What is the value of j after this code executes?

Respuesta :

kaevras
kaevras kaevras
  • 08-01-2017
Let's go through step by step, starting from inside the while loop.


Is i > 0? Yes. Continue.

ITERATION 1:
i now equals 10 (100 / 10)
j now equals 1 (1 + 10 % 5)

Is i > 0? Yes. Continue.

ITERATION 2:
i now equals 10 (10 / 1)
j now equals 0 (1 + 1 % 5)

Is i > 0? Yes. Continue.

ITERATION 3:
i = i / j; now generates a DivideByZeroException, thus we get a run-time error.
Answer Link

Otras preguntas

Find the greatest common factor of 27ab3 and 90a²b.​
2. In the middle of the night, the telephone screamed out my name over and over. Image conveyed: Two things compared:
(06.02 MC) The lengths of two sides of a triangle are shown. Side 1: 3x2 - 2x - 1 Side 2: 9x + 2x2 - 3 The perimeter of the triangle is 5x3 + 4x2 - x - 3. Part
State the conclusion based on the results of the test. According to the Federal Housing Finance​ Board, the mean price of a​ single-family home two years ago wa
How many terms does the given polynomial have: 5x2 + 2y - 3x + 2? A) 1 B) 2. C) UN 3. D) 4
what is the predecessor of these number question 1) ___________ 10,000 2) ___________ 7010 3) ___________ 9000
longitude and latitude definition for class 6th​
Please help fast! give me the equation
please solve quickly ​
Fill in the missing number. % of 500,000 = 50,000