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
What is the slope of the line that passes through the points (-9,-9) and (-6,-12)? Write your answer in simplest form.
Sedaia [141]

Answer:

your slope is 1

Step-by-step explanation:

You would use the formula y2-y1/x2-x1=m you would do -12-(-9)/-6-(-9)

which would give you 3/3 which simplifies to 1.

3 0
3 years ago
Can someone answer this please!!! I only have 5 mins and u will get Brainly too :)
luda_lava [24]
Better quality would help, have a good day/night
4 0
3 years ago
Determine if the shape shown is a triangel squear rectangel or hexagon or other
jonny [76]
You can determine the shape if it is a triangle, square, rectangle, or hexagon (or other) by seeing how many sides it has.
a triangle has 3 sides.
a square has 4 sides.
a rectangle also has 4 sides.
a pentagon has 5 sides.
a hexagon has 6 sides.
8 0
3 years ago
What is the value of the rational expression below when x is equal to 4
Zanzabum
\displaystyle  \frac{4+20}{4+4}= \frac{24}{8}=3
3 0
3 years ago
Read 2 more answers
Product A is a 12-ounce bottle of generic mouthwash that sells for $1.15. Product B is a 24-ounce bottle of mouthwash that costs
adoni [48]
12 oz = 1.15
24 oz = 2.79
Let's see if 2x12oz is equal, less, or more than the 24oz.
1.15 x 2 = 2.30
2.30<2.79
The 12 oz is a better buy.
3 0
3 years ago
Other questions:
  • Which phrase describes the pattern? 1, 7, 19, 43...Question 2 options: add 6 ,multiply by 3 and then add 1 multiply ,by 3 and th
    14·1 answer
  • Howard has a garden in the shape of a rectangle. The length is 5.4 meters The width is 1.5 meters Howard will increase both the
    14·1 answer
  • Find the nth term of this sequence -2 3 8 13 18
    14·1 answer
  • 1. Each crayon costs $3.00 and each egg costs $5.00. How much do 80 crayons cost?
    9·1 answer
  • Joey collects football cards and baseball
    5·1 answer
  • How many different ways can you make 50 cents if you have 1 quarter, 5 dimes, and 10 nickels?
    6·1 answer
  • Carla packed her suitcase for her summer vacation. She packed four shirts: red, green, white and blue. She packed two belts: bro
    6·2 answers
  • A 5-foot peice of ribbon cost 13.20 dollars. WHAT is the price per inch
    15·1 answer
  • Write 0.79 repeating as a fraction.
    6·2 answers
  • 10. What is the value of ? A. 47.5° B, 85° 95° C. 95° С D. 132.59​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!