nerdexam
CompTIA

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.

Software Development

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)
  • A
    3% (1)
  • B
    6% (2)
  • C
    3% (1)
  • D
    87% (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.

AIF

IF is a conditional statement that executes code once if a condition is true, not for repetition.

BELSE

ELSE is part of an IF-ELSE structure and is used for alternative execution, not for looping.

CRETURN

RETURN is used to exit a function and optionally send back a value, not for repeating statements in a loop.

DWHILECorrect

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

#looping constructs#iteration#programming fundamentals

Community Discussion

No community discussion yet for this question.

Full FC0-U61 Practice