231k views
0 votes
Consider the following subroutine:

static void showFrame(int frameNum)
Now study the following two statements

1) for (int i = 1; i <= 30; i++)
showFrame(i);

2) for (int play = 0; play < 10; play++) {
for (int i = 1; i < 30; i++)
showFrame(i);
}

Select the best description of statements 1) and 2):
Select one:
a. 1) displays 29 animation frames in reverse order; 2) replays the animation 10 times.
b. 1) displays 30 animation frames in order; 2) replays the animation 10 times.
c. 1) displays 29 animation frames in order; 2) replays the animation 9 times.
d. 1) displays 31 animation frames; 2) replays the animation 10 times.

1 Answer

7 votes

Final answer:

The best description of statements 1) and 2) is 1) displays 29 animation frames in reverse order; 2) replays the animation 10 times.

Step-by-step explanation:

The best description of statements 1) and 2) is a. 1) displays 29 animation frames in reverse order; 2) replays the animation 10 times. The best description of statements 1) and 2) is 1) displays 29 animation frames in reverse order; 2) replays the animation 10 times.

In statement 1), the for loop iterates from 1 to 30, calling the showFrame() subroutine with each value of i. This displays 29 animation frames in reverse order, starting from frame 30 and ending at frame 1. In statement 2), there are nested for loops. The outer loop iterates 10 times, and the inner loop iterates from 1 to 29. This replays the animation 10 times.

User Dimitar Genov
by
8.7k points