Question discussion

What happens if the condition in a while loop is false at the start?

359053Medium DSSSB TGT Computer Science 0 replies 0 views
0
What happens if the condition in a while loop is false at the start?
  • AThe loop runs once and then terminates.
  • BThe loop does not run at all.
  • CThe loop throws an error.
  • DThe loop runs infinitely.
Correct answer: B

Explanation

A while loop checks its condition first, so if it is false at the start the body never runs.

Discussion 0

Nobody has replied yet. Start the discussion!