47.5k views
3 votes
Pedro needs to write a block of code that will repeat a loop six times. Which type of loop should he use?

O for
O else
O else if
O while

User Lezir Opav
by
4.3k points

2 Answers

2 votes

Answer:

for loop

Step-by-step explanation:

sorry im late

User Tbrooke
by
4.5k points
4 votes

Answer:

The answer to this question is given below in the explanation section.

Step-by-step explanation:

Petro needs to write a block of code that repeats six times. The given options in this question that what should he use to implement the six times a block of code are:

  1. for
  2. else
  3. else if
  4. while

The correct option to this question is: 1 -for-loop.

So, Pedro needs to use for-loop to write a block of code that will repeat a loop six times. Because when you use for-loop, you know how many iterations are in a loop to execute a block of code. So in this case, the number of iteration is known. Therefore, Pedro needs to use for-loop.

While other options are not correct because:

Else and else are used to make decisions, these are not used to repeat a block of code. These are code branching statements in simple words. While while-loop is used to iterate/loop a block of code but when you don't know the exact number of repetitions.

User Tmaximini
by
4.5k points