1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Vsevolod [243]
3 years ago
10

EX 6.1 How many iterations will the following for loops execute? for (int i = 0; i < 20; i+ +) { } for (int i = 1; i <= 20

; i+ +) { } for (int i = 5; i < 20; i+ +) { } for (int i = 20; i > 0; i- -) { } for (int i = 1; i < 20; i = i + 2) { } for (int i = 1; i < 20; i *= 2) { }
Mathematics
1 answer:
Romashka-Z-Leto [24]3 years ago
6 0

Answer:

20, 20, 15, 20, 10, and 5 iterations respectively

Step-by-step explanation:

The loop "for (int i = 0; i < 20; i+ +)" starts at i=0 and increases the counter i by 1 at the end of each iteration. The counter must be less than 20, so the values of i in the loop are 0,1,2,3,...,19. These are 20 values, and thus the code iterated 20 times.

The loop "for (int i = 0; i < 20; i+ +)" starts at i=1 and increases the counter i by 1 at the end of each iteration. The counter can't exceed 20, so the values of i in the loop are 1,2,3,4,...,20. These are 20 values, and thus the code iterated 20 times.

Similarly, in "for (int i = 5; i < 20; i+ +)" i takes the 15 values are 5,6,7,...,19. Hence, the code iterated 15 times.

The loop "for (int i = 20; i > 0; i- -)" starts at i=20 and decreases the counter i by 1 at the end of each iteration, so the values of i in the loop are 20,19,18,...,1. These are 20 values, then we have 20 iterations.

The loop "for (int i = 1; i < 20; i = i + 2)" starts at i=1 and increases the counter i by 2 at the end of each iteration. The values of i in the loop are 1,3,5,7,...,19. These are 10 values, and thus the code iterated 10 times.

The loop "for (int i = 0; i < 20; i+ +)" starts at i=1 and multiplies the counter i by 2 at the end of each iteration, so the values of i in the loop are 1,2,4,8,16. Then we have 5 iterations.

You might be interested in
Please help me with this​
stiks02 [169]

Answer:

1 is 40/7

Step-by-step explanation:

8 0
4 years ago
Read 2 more answers
The recipe for a batch of applesauce uses 2 and one-half pounds of apples. If Michael wants to make Three-fourths of a batch of
RideAnS [48]

Answer:

The answer is the option C

Step-by-step explanation:

Hope it help

6 0
3 years ago
Read 2 more answers
Pls help ;/
Sidana [21]

Answer:

-3

Step-by-step explanation:

-3 because

9-12

Good luck! follow me for more help!

7 0
3 years ago
Read 2 more answers
3/4 of Hari's marbles are black and 1/5 are green. What would be the ratio of black marbles to the green marbles?
Kazeer [188]

Answer:

➩ 15 : 4 is the ratio

Step-by-step explanation:

Hari's marbles are = ¾ which is black in color.

And ⅕ of his marbles are green in color.

Forming in ratio :

\sf \to \:  \frac{3}{4}  : \frac{1}{5}  \\  \sf \to \:  \frac{3}{4}  \times  5 \\  \sf \to \:  \frac{15}{4}  \\  \sf \to \: 15 : 4 \: ans.

4 0
3 years ago
Read 2 more answers
Trevor ran a race in 1 4/5 hours. He ran a total of 8 1/3 miles. How far did he run in one hour?
gulaghasi [49]

Answer:

4.63

Step-by-step explanation:

4/5 of an hour is 48 minutes

1 4/5 hour is 60 + 48

which is

108 minutes

he ran 8 1/3 miles in 108 minutes

so

(8 1/3 times 60 ) ÷ 108

which =

4.6296296296 miles in one hour

6 0
3 years ago
Read 2 more answers
Other questions:
  • Two bags of flour have a total weight of 27lb. If one lb is removed from the lighter bag, the heavier bag will weigh twice as mu
    9·2 answers
  • Select all the possible ways to transform the letter V in a single transformation so that its point is up rather than down.
    7·1 answer
  • A total of 759 tickets were sold for school play. They were either adult tickets or student tickets. There were 59 more student
    9·2 answers
  • To which of the following sets does the number 0 belong?
    5·2 answers
  • The object is made of six cubes, each with edges 15 centemeters long. what is the volume in cubic centemeters of the object
    13·2 answers
  • Subtract the fraction and simplify the answer 13/15 - 1/5
    10·1 answer
  • A sixth grade class will clean a beach that is 3 1/2 miles long. Each class will divide into 4 groups. Each group will clean an
    5·1 answer
  • What is the measure of c is
    14·1 answer
  • Which expression is equivalent to cube root of 216 x superscript 27 ? 6x3 6x9 72x3 72x9
    5·1 answer
  • Look at this figure <br> Which of these can all be found on the figure
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!