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
A point located at (-4, 5) is translated left 5 units. What are the coordinates of the image?
Nimfa-mama [501]
I believe the answer would be (-9,5)
6 0
3 years ago
Determine whether each statement is always, sometimes, or never true. Explain your reasoning. (By the way, this has to do with a
Norma-Jean [14]
A).  |x| = |-x|
This is always true.
The definition of 'absolute' value is 'size of the number without its sign'.
That's what this expression says.

b).  |x| = -|x|
This is never true, because an absolute value is never negative.
This one would true if x=0 .  So maybe some people might say
it's sometimes true, but that doesn't feel right to me.  I say never.

c).  |-x| = -|x|
This looks to me like exactly the same situation as (b),
and I would say all the same things about it.
6 0
2 years ago
Read 2 more answers
What is the decimal equivalent to 6/11
Elina [12.6K]

Answer:

0.54545454

Step-by-step explanation:


7 0
3 years ago
Read 2 more answers
21. Jim loves nuts. He plans to spend at most $24 to buy cashews and peanuts for after work
FinnZ [79.3K]

He can buy 5 of the $3 nut and 1 of the $5 nuts.

5x3=15

5x1=5

15+5=20 and that’s less than 24.

So Jim can use $20 to buy the $3 one 5 times and the $5 one 1 time.

4 0
2 years ago
the area of the triangle below is 1/4 square meters. what is the length of the base. express your answer in simplest form
Alexeev081 [22]

Answer:

4/5

Step-by-step explanation:

<u>Given</u>,

Area of the triangle = 1/4 square meters

From the diagram,

Height = 2/5 m

<u>To find</u> : Length of the base

<u>Formula</u> : -

A = bh/2

Here,

A denotes Area

b denotes Base

h denotes Height

A = 1/4

h = 2/5

A = bh/2

Cross multiply,

A * 2 = bh

2A = bh

2 * (1/4) = b * (2/5)

(1 * 2)/4 = (b * 2)/5

2/4 = 2b/5

1/2 = 2b/5

Cross multiply,

1 * 5 = 2 * 2b

5 = 4b

b = 4/5 meters

Hence,

The length of the base is 4/5 meters.

5 0
2 years ago
Other questions:
  • Are These Dates Correct For When These colonies were founded?
    8·1 answer
  • How is the total price including sales tax calculated
    7·1 answer
  • 3/5 in two equivalent forms
    10·1 answer
  • HELP ME PLS HURRY PLEASE PLEASE
    12·1 answer
  • Can someone answer fast please bc i have a test
    5·2 answers
  • What is the rate of change of the line on the graph
    9·1 answer
  • 2x and 3x are like terms
    13·1 answer
  • I need help asap please
    10·2 answers
  • Which Graph Shows A System With One Solution?
    13·1 answer
  • 24+89<br> A.113<br> B.34<br> C.87<br> D.90
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!