Ask Question
2 September, 10:48

If number is 20, what is printed to the console after this code is executed?

for (int i = 3; i < = number; i + = 2)

{

if (number % i = = 0)

{

System. out. println (i);

if (i = = number)

System. out. println ("special");

break;

}

}

a. 5

b. 5

5

special

c. 20

special

d. 5

special

e. 2

+1
Answers (1)
  1. 2 September, 13:35
    0
    Option a is the correct answer for the above question

    Explanation:

    The above question code has one for-loop which runs two times only for the value of number=20. It is because when the if-condition will true then the loop will be exit because it holds the break statement which exits the for-loop when the if-condition will be true. So when the first time 20 will divide by 3 then if-condition will fail, but when the 20 will be divide by the 5, then the if condition will be true and the 5 will be printed as output. Then the second if-condition will false because it will be true for the 20 value of i. Hence option a is the correct answer while the other is not correct because others will not hold the output of this code.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “If number is 20, what is printed to the console after this code is executed? for (int i = 3; i < = number; i + = 2) { if (number % i = = 0) ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers