Bird
0
0

Which of the following is the correct syntax for a while loop in Kotlin?

easy📝 Syntax Q3 of 15
Kotlin - Loops and Ranges
Which of the following is the correct syntax for a while loop in Kotlin?
Awhile condition { /* code */ }
Bwhile: (condition) { /* code */ }
Cwhile (condition) { /* code */ }
Dwhile (condition); { /* code */ }
Step-by-Step Solution
Solution:
  1. Step 1: Review Kotlin while syntax

    Kotlin requires parentheses around the condition and braces for the loop body.
  2. Step 2: Identify correct syntax

    while (condition) { /* code */ } matches the correct syntax: while (condition) { /* code */ }.
  3. Final Answer:

    while (condition) { /* code */ } -> Option C
  4. Quick Check:

    Correct while syntax uses parentheses and braces = B [OK]
Quick Trick: while needs parentheses and braces in Kotlin [OK]
Common Mistakes:
MISTAKES
  • Omitting parentheses
  • Adding semicolon after condition
  • Using colon after while

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kotlin Quizzes