Bird
0
0

Which of the following correctly demonstrates a nested while loop structure in C?

easy📝 Syntax Q3 of 15
C - Loops
Which of the following correctly demonstrates a nested while loop structure in C?
Awhile(i < 3) { while(j < 2) { /* code */ } }
Bwhile(i < 3); while(j < 2) { /* code */ }
Cwhile(i < 3) { j < 2; /* code */ }
Dwhile(i < 3) { while(j < 2); /* code */ }
Step-by-Step Solution
Solution:
  1. Step 1: Understand nested loops

    A nested loop means one loop inside another, both properly structured.
  2. Step 2: Analyze options

    while(i < 3) { while(j < 2) { /* code */ } } correctly nests one while loop inside another with braces.
  3. Step 3: Identify incorrect syntax

    Options B, C, and D misuse semicolons or lack proper braces, breaking the loop structure.
  4. Final Answer:

    while(i < 3) { while(j < 2) { /* code */ } } -> Option A
  5. Quick Check:

    Proper nesting requires braces and no stray semicolons [OK]
Quick Trick: Nested loops need braces and no stray semicolons [OK]
Common Mistakes:
  • Using semicolon immediately after while condition
  • Missing braces for nested loops
  • Incorrect loop body placement

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Quizzes