What is the output of the following code?

21 0

Get full Expert solution in seconds

$1.97 ONLY

Unlock Answer

EXPERT ANSWER

the answer is the A part.

The for loops for(temp1 = 1 ……..) is used for reversal of the array.

However as the for loop only runs till length-5 it doesn’t affect the last 5 elements of the list.

So you need to look for a list whose last 5 digits are in ascending order of 3 and the starting digits are in descending order of 3. Which is part A

MORE ANSWER

Initially all array numbers are 0

Each time 3 is added to the previous number

list after first for loop is

0 3 6 9 12 15 18 21 24 27

Next for loop runs for 4 times. Each time the loop executes, list after the code block is

3 0 6 9 12 15 18 21 24 27
6 3 0 9 12 15 18 21 24 27
9 6 3 0 12 15 18 21 24 27
12 9 6 3 0 15 18 21 24 27

Finally the last for loop is used to print the above array.

Answer

Option a

12 9 6 3 0 15 18 21 24 27