The input to the following algorithm is a positive integer. The goal is to find the digit in the hundreds place of the integer. (For example, if we input 28398, we want the algorithm to output 3.)

Below is the proposed algorithm, but the values of X and Y are missing:

Step 1: Divide the input by X. Call the quotient and ignore the remainder.

Step 2: Now divide by Y. Ignore the quotient and call the remainder

Step 3: Return

What X, Y will allow this algorithm to correctly find the hundreds digit of the input? Put X in the first blank and Y in the second blank.

Note: We would say that has a quotient of 2 and a remainder of 1.

Respuesta :

The first division should reduce the hundreds digit to the units digit by dividing by 100.  Ignoring remainder means ignoring the previous units and tens digits.
The second division, where we keep the remainder is to extract the units digit by ignoring the quotient.  So we divide by 10.  The discarded digits are the tens and higher digits.

Answer:

X = 100 and Y = 10

Explanation:

Let's do the example, where input = 28398

Step 1: Divide the input by 100. Call the quotient and ignore the remainder.

28398/100 = 283.98, quotient = 283, remainder = 89

Step 2: Now divide by 10. Ignore the quotient and call the remainder  

283/10 = 28.3,  quotient = 28, remainder = 3

Step 3: Return 3