An IT technician is writing a program that needs to perform a task 10 times. Which of the following code structures should the technician use to repeat the task exactly 10 times?
You selected this option
while loop without a counter or condition that stops at 10
You selected this option
if statement
You selected this option
do-while loop that checks a condition unrelated to the iteration count after executing the block
A 'for' loop is used when you know in advance how many times you want to execute a statement or a block of statements. In the context of the task required by the IT technician, a 'for' loop allows the program to perform the task exactly 10 times. The other options do not specify the number of repetitions or relate to entirely different programming concepts.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is a 'for' loop in programming?
Open an interactive chat with Bash
Why are 'if' statements not suitable for repeating tasks?