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
14.89 divided by 0.02
Aneli [31]

Answer:

744.5

Step-by-step explanation:

4 0
3 years ago
Read 2 more answers
Maggie buys 5 apples and 4 oranges for $10 and Lynn buys 5 apples and 5 oranges for $11. What is the price for an apple and what
nlexa [21]
Make 2 eqn, let a be apples and o be oranges:

1. 5a + 4o = 10
2. 5a + 5o = 11

set up an elimination:
1. minus 2.
5a + 4o = 10
- 5a + 5o = 11
____________
o = 1

sub “o” into one of the eqn

5a + 5(1) = 11
5a = 11-5
5a = 6
a = 6/5
a = 1.2

therefore, an orange costs $1.00 and an apple costs $1.20

6 0
4 years ago
5x-60 = -60 +2x +3x<br> how many solutions does the equation have
xeze [42]

Answer:

infinitely \: many \: solution

Step-by-step explanation:

1) Cancle -60 on both sides.

5x = 2x + 3x

2) Simplify 2x + 3x to 5x.

5x = 5x

3) Since both sides are equal, there are infinitely many solutions.

infinietly \: many \: solution

<u>Therefor</u><u>,</u><u> </u><u>this</u><u> </u><u>equation</u><u> </u><u>has</u><u> </u><u>infinitely</u><u> </u><u>many</u><u> </u><u>solutions</u><u>.</u>

5 0
3 years ago
Write 27 as a power and as repeated multiplication
Oxana [17]

Answer:

3*3*3

3^3

Step-by-step explanation:

27 = 9*3

    = 3*3*3

    = 3^3

6 0
3 years ago
Read 2 more answers
What is the meassure of XYZ in the diagram below HELP ASSAP :)
yaroslaw [1]
39° or B that should be it
8 0
3 years ago
Read 2 more answers
Other questions:
  • Help,..............................
    14·1 answer
  • Gavin and Jack are practicing shots against their goalie. On their last 15 attempts, Gavin made 6 and Jack made 7. Based on this
    13·1 answer
  • HELP HELP HELP Read carefully before answering The cargo weight in Morten's truck cannot be greater then 3 tons. He has 5,000 po
    7·1 answer
  • a boy pulls on a 50-kg wagon with a constant force of 400 newtons. what is the wagons acceleration? ​
    14·1 answer
  • A horse has 13 entries and one person owns 4 of those horses . Assuming that there are no ties , what is the probability that th
    5·1 answer
  • How much more intrest is owed on 900 dollars for 9 months than 6 months
    12·1 answer
  • What is the slope of tne line to 4x+6y=12
    5·2 answers
  • Equal Sides<br>4 what is that shape​
    14·2 answers
  • Please help....Which fraction has the greatest value?
    12·2 answers
  • Please help me ASAP...​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!