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
Kaitlin is on a long car trip. Everytime she stops for gas she loses 15 minutes of travel time. If she has to stop fives times h
Nastasia [14]
She will be 75 minutes late because you take the 15 minutes per stop and multiply it by the five stops.
7 0
4 years ago
Read 2 more answers
(sinB+1)(cosBtanB-1)
Karo-lina-s [1.5K]
Here you go!!! I hope this helps

6 0
3 years ago
Find the distance between theses points:(8,0),(-6,6). Round answer to nearest tenth if necessary.
11111nata11111 [884]

Answer:

Chicken strips

Step-by-step explanation:

Dont ask they are just on my mind

7 0
3 years ago
-PLEASE HELP ME WITH THIS <br><br> THANKS TO ALL HELPFUL USERS
Marizza181 [45]
The answer is the first option. 


4 0
4 years ago
Read 2 more answers
What is <br> (x - 3)(x +9)
wel

Answer:

x^2 +6x-27

Step-by-step explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • Help me correct this plz
    7·2 answers
  • Find the volume of this square<br> based pyramid.<br> 5ft<br> 6 ft<br> [? ]ft
    9·1 answer
  • Solve each system of equation<br> Y=-3x+5 <br> 5x-4y=-3
    14·1 answer
  • Which of the following is the best estimate of the direction of the given vector?
    15·1 answer
  • ANSWER NEEDED NOW!!!!!!!!!!!​
    12·1 answer
  • Mr. Matthews bought his house in New York City in 2020. If the trend continued, how much was he likely to have paid?
    12·1 answer
  • What is 7 / 2 0 to 5
    7·1 answer
  • If there are 16 boys and 32 girls in a room, fill out all of the possible ratios of boys to girls that could be made. They alrea
    7·1 answer
  • SOMEONE PLEASE HELP ASAP!!!?? ILL GIVE U BRAINLIST
    9·2 answers
  • I need help with an area math question
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!