In the following code, what will be the last number to print to the screen before the program finishes?
The code provided is:
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Explanation:
The loop iterates from
i = 0
toi = 9
(sincerange(10)
stops before 10).i
is even (i % 2 == 0
), it printsi
.i
is odd, it prints2 * i
.Let’s go through each iteration to see what prints:
0
2 * 1 = 2
2
2 * 3 = 6
4
2 * 5 = 10
6
2 * 7 = 14
8
2 * 9 = 18
The last number printed is 18.
Answer: