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
An item is priced at $13.22. If the sales tax is 4%, what does the item cost including sales tax
schepotkina [342]

sales tax = 13.22 * .04

sales tax = .53  (round to the nearest cent)

total cost = cost of item + sales tax

total cost = 13.22 + .53

total cost = 13.75

8 0
3 years ago
Read 2 more answers
In the park, Bryce hikes 4 1/2 mi and Jessie hikes 6 7/16 mi. How much farther does Jessie hike than Bryce? Express your answer
soldier1979 [14.2K]

is simply the difference of both amounts, but firstly let's convert the mixed fractions to improper, and subtract.


\bf \stackrel{mixed}{4\frac{1}{2}}\implies \cfrac{4\cdot 2+1}{2}\implies \stackrel{improper}{\cfrac{9}{2}}&#10;\\\\\\&#10;\stackrel{mixed}{6\frac{7}{16}}\implies \cfrac{6\cdot 16+7}{16}\implies \stackrel{improper}{\cfrac{103}{16}}&#10;\\\\[-0.35em]&#10;\rule{34em}{0.25pt}\\\\&#10;\stackrel{Jessie}{\cfrac{103}{16}}-\stackrel{Bryce}{\cfrac{9}{2}}\implies \stackrel{\textit{our LCD is 16}}{\cfrac{(1)103-(8)9}{16}}\implies \cfrac{103-72}{16}\implies \cfrac{31}{16}\implies 1\frac{15}{16}

5 0
4 years ago
Read 2 more answers
PLEASE HELP I NEED IT: You have a triangle with one 70 degree angle and one 40 degree angle. What is the measure of the other an
Rus_ich [418]

Answer:

70

Step-by-step explanation:

all the angles of a triangle sum 180, so 180 - (70 + 40) = 70

5 0
3 years ago
Read 2 more answers
Please answer correctly my answer depends on this
Ahat [919]

Answer:

x = -3 and x= 3

Step-by-step explanation:

4 0
3 years ago
What is 5+2? Ive been totally stuck on this for the longest time. I really need help
eduard

that's a tricky one!

but it is 7 i believe

5 0
3 years ago
Other questions:
  • While working on a large portrait, Juan used 16 1/3 tubes of paint and 5 1/4 ounces of brush cleaner. Juan is visiting an art su
    9·1 answer
  • A coin contains 1.25 grams of nickel and 3.75 grams of copper, for a total weight of 5 grams. What percentage of the metal in th
    8·1 answer
  • Simplify 2(x + y) + 3(x + y). <br> 2xy + 3xy <br> 5xy <br> 5x + 5y
    11·2 answers
  • Erica earns a rebate each month on her meals and movie tickets. She earns $3 for each movie ticket and $0.80 for each meal. Last
    12·1 answer
  • A cylindrical tank is half-full of oil.
    6·2 answers
  • A piece of fabric is 2 yards long. Marcus puts one patch at each end of the fabric and at each quarter foot mark. How man patche
    11·1 answer
  • Write an equation in slope-intercept equation of each line from the graph (10,3) and (-2,5)
    8·1 answer
  • Find the value of x in the triangle shown below.
    14·2 answers
  • A car dealership is advertising a car for $16,299.99. If the sales tax rate is 6.5 percent, what
    11·1 answer
  • PLEASE HELP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!