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
If the graph of f(x) = x is shifted up 9 units, what would be the equation of the new graph?
goblinko [34]

Answer:

x+9

Step-by-step explanation:

f(x) = x, going up 9

that is y=x, going up 9

if you wnat to go up, subtract 9 from y

y -9 = x

y=x+9

convert back to f(x)

f(x) = x+9

5 0
3 years ago
Find the sum of the first 9 terms in the following geometric series 7+21+63+
Zielflug [23.3K]

Answer: 68887

Step-by-step explanation: the geometics series is (the previous number in the series) x 3, so 63 x 3 =189 x 3 =567 x 3 = 1701 x 3 = 5103 x 3 =15309 x 3 = 45927 and you add all those numbers up to get 68887

4 0
3 years ago
I need help here is the problem
leva [86]

Answer:

12.96pi

Step-by-step explanation:

area = r^2 *pi

= 3.6^2 * pi

= 12.96pi

5 0
2 years ago
Read 2 more answers
When an article is sold for $132.00, a profit of 10% is made. The cost of the<br> article is?
Orlov [11]

Answer:

118.8

Step-by-step explanation:

Profit=10%

=10/100 × $132

=$13.2

Cost price=Selling price- Cost price

=$132-$13.2

=$118.8

3 0
2 years ago
A recipe has 3 tablespoons of cinnamon and 4 tablespoons of vanilla how many tablespoons of cinnamon and I needed per tablespoon
Gre4nikov [31]
I don't understand the English. I would've loved to help though. 
7 0
3 years ago
Other questions:
  • A scuba diver is exploring at an elevation of -12.2 meters. As the diver rises to the surface, she plans to stop and rest briefl
    10·1 answer
  • What are the non overlapping angles
    6·1 answer
  • Which statement is true about credit cards?
    14·1 answer
  • USA Today reported that about 47% of the general consumer population in the United States is loyal to the automobile manufacture
    6·1 answer
  • Bulan rows on a crew team. her team rows their boat at a split (rate) of 2 min over 500 m
    11·1 answer
  • Which pair of coordinates represents point p in the graph
    7·2 answers
  • Jacqueline will spend a fair spinner with the numbers 0 1 2 3 and 4 a total of three times if event a spinner lands on numbers a
    12·1 answer
  • Last year at RT University, the ratio of the number of
    9·1 answer
  • Identify two segments that are marked parallel to each other on the diagram below.(diagram is not to scale)
    10·1 answer
  • Rational exponents; what do i do???
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!