FC0-U61 · Question #483
Which of the following programming constructs would be used to repeat a statement 100 times in a loop?
The correct answer is D. WHILE. To repeat a statement a specific number of times in a loop, a programming construct that allows for iteration based on a condition is required. A WHILE loop can be used to achieve this by controlling a counter.
Question
Which of the following programming constructs would be used to repeat a statement 100 times in a loop?
Options
- AIF
- BELSE
- CRETURN
- DWHILE
How the community answered
(31 responses)- A3% (1)
- B6% (2)
- C3% (1)
- D87% (27)
Why each option
To repeat a statement a specific number of times in a loop, a programming construct that allows for iteration based on a condition is required. A WHILE loop can be used to achieve this by controlling a counter.
IF is a conditional statement that executes code once if a condition is true, not for repetition.
ELSE is part of an IF-ELSE structure and is used for alternative execution, not for looping.
RETURN is used to exit a function and optionally send back a value, not for repeating statements in a loop.
A WHILE loop executes a block of code repeatedly as long as a specified condition is true; by using a counter variable that increments with each iteration, it can be configured to repeat the statement exactly 100 times.
Concept tested: Programming - Looping constructs
Source: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/while
Topics
Community Discussion
No community discussion yet for this question.