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
Which mapping diagram does NOT represent a function from x &gt; y ?
Firdavs [7]

Answer:

A

Step-by-step explanation:

In a function, each x value must have a singular y value. This means that one x-value (the values on the left) may not have a line pointing to 2 different y-values (the values on the right). In the first relation, the x-value of 6 points to both 4 and 6. This means that the value repeats, and in a function x-values cannot repeat.

However, y-values can repeat. So, situations like that seen in D, where both the x-values of 2 and 4 equal the y-value of 6 are fine.

5 0
2 years ago
Sorry my brain a bit dumb, I need someone more brainly to solve this
DerKrebs [107]
I hope my ans is correct!! used some algebra here but yea i hope its still comprehensible!

4 0
3 years ago
Read 2 more answers
A radio station is offering a promotion for a concert. Every 6th caller will receive a T-shirt and every 10th caller will receiv
ExtremeBDS [4]
The 30th caller I don’t have anything else to say but my answer has to be longer to send that’s all hopes this helps :)
4 0
3 years ago
What is the value of the fraction of -3/4 divided 2/5
tangare [24]

Answer: 2/5 ÷ 2 = 2/10 as simplified as 1/5 in fraction form. 2/5 ÷ 2 = 0.2 in decimal form.

5 0
3 years ago
Devin is collecting signatures for a petition to open a new park in her town. She needs to collect at least 1,000 signatures bef
steposvetlana [31]

Answer:

The correct opion is;

7 ≤ p

Step-by-step explanation:

The number of signatures Devin needs to collect = 1,000 signatures

The numer of signatures Devin has already = 380 signatures

The number ofsignatures each petition page can hold = 80 signatures

Therefore;

The number of extra signatures required = 1,000 - 380 = 680 signatures

The number of petition pages required = 1,000 petitions /(80 signatures/page)   = 12.5 pages

The number of pages already filled = 380 petitions /(80 signatures/page) = 4.75 pages

The number of pages remaining, p = 12.5 - 4.75 = 7.75 pages

Therefore, 7 ≤ p.

8 0
4 years ago
Read 2 more answers
Other questions:
  • 5/8 of a fence has been built. If there is still 40 feet to be built, how long will the fence be?
    7·1 answer
  • The coordinate of point R and S are (4,3)and(1,6)what is the distance between the point
    12·1 answer
  • Y = 2x( z+ 3 ) find y if z = 2 and x = 4 whats the formula​
    5·1 answer
  • A group of 5 friends spent a total of $18 on a bottle of juice and a package of dried fruit for each of them each juice cost $ 1
    15·2 answers
  • Alistair has 5 half-pounds chocalate bars. It takes 1 1/2 pounds of chocalate,broken into chunks, to make a batch of cookies. Ho
    13·2 answers
  • What is 9/5 as a persentage
    5·2 answers
  • Help I need to find area and it’s due by 8
    10·2 answers
  • PLEASE HELP!! can someone please explain what i did wrong?
    5·1 answer
  • The traffic flow rate (cars per hour) across an intersection is
    9·1 answer
  • Help do y’all know this! Please if u do i need the answer
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!