Bird
Raised Fist0
Cprogramming~20 mins

Continue statement - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Continue Statement Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate
2:00remaining
Output of loop with continue
What is the output of this C program?
C
#include <stdio.h>

int main() {
    for (int i = 1; i <= 5; i++) {
        if (i == 3) {
            continue;
        }
        printf("%d ", i);
    }
    return 0;
}
A1 2 4 5
B2 3 4 5
C1 2 3 4 5
D1 2 3 4
Attempts:
2 left
💡 Hint
Remember that continue skips the rest of the loop body for the current iteration.
🧠 Conceptual
intermediate
2:00remaining
Effect of continue in nested loops
In the following nested loops, how many times will the inner printf execute?
C
#include <stdio.h>

int main() {
    int count = 0;
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (j == 1) {
                continue;
            }
            count++;
        }
    }
    printf("%d", count);
    return 0;
}
A0
B6
C3
D9
Attempts:
2 left
💡 Hint
Count how many times the inner loop skips printing when j == 1.
🔧 Debug
advanced
2:00remaining
Identify the error caused by continue
What error will this code produce when compiled or run?
C
#include <stdio.h>

int main() {
    int i = 0;
    while (i < 5) {
        i++;
        if (i == 3) {
            continue;
        }
        printf("%d ", i);
    }
    return 0;
}
APrints: 1 2 4 5
BCompilation error
CInfinite loop
DPrints: 1 2 3 4 5
Attempts:
2 left
💡 Hint
Check how i is incremented and when continue is called.
📝 Syntax
advanced
2:00remaining
Which option causes a syntax error?
Which of the following code snippets will cause a syntax error due to incorrect use of continue?
Ado { if (0) continue; } while(0);
Bfor (int i = 0; i < 5; i++) { if (i == 2) continue; printf("%d", i); }
Cwhile (0) { continue; }
Dif (1) { continue; }
Attempts:
2 left
💡 Hint
Remember continue can only be used inside loops.
🚀 Application
expert
2:00remaining
Count numbers skipping multiples of 4
What is the output of this program that uses continue to skip multiples of 4?
C
#include <stdio.h>

int main() {
    int sum = 0;
    for (int i = 1; i <= 10; i++) {
        if (i % 4 == 0) {
            continue;
        }
        sum += i;
    }
    printf("%d", sum);
    return 0;
}
A40
B50
C43
D55
Attempts:
2 left
💡 Hint
Add numbers from 1 to 10 but skip those divisible by 4.

Practice

(1/5)
1. What does the continue statement do inside a loop in C?
easy
A. Skips the rest of the current loop iteration and moves to the next iteration
B. Stops the entire loop immediately
C. Exits the current function
D. Restarts the program from the beginning

Solution

  1. Step 1: Understand the role of continue

    The continue statement does not stop the loop but skips the remaining code in the current iteration.
  2. Step 2: Effect on loop execution

    After continue, the loop immediately proceeds to the next iteration, ignoring any code below it in the current cycle.
  3. Final Answer:

    Skips the rest of the current loop iteration and moves to the next iteration -> Option A
  4. Quick Check:

    continue skips current iteration [OK]
Hint: Remember: continue skips current loop step, not whole loop [OK]
Common Mistakes:
  • Confusing continue with break
  • Thinking continue exits the function
  • Assuming continue restarts the program
2. Which of the following is the correct syntax to use continue inside a for loop in C?
easy
A. continue;
B. continue()
C. continue{}
D. continue[]

Solution

  1. Step 1: Recall correct statement syntax

    In C, continue is a statement and must end with a semicolon.
  2. Step 2: Identify valid syntax

    Only continue; is valid; parentheses, braces, or brackets are incorrect.
  3. Final Answer:

    continue; -> Option A
  4. Quick Check:

    Statement ends with semicolon [OK]
Hint: Statements end with semicolon; continue is no exception [OK]
Common Mistakes:
  • Adding parentheses after continue
  • Using braces or brackets with continue
  • Omitting the semicolon
3. What is the output of the following C code?
for (int i = 1; i <= 5; i++) {
    if (i == 3) continue;
    printf("%d ", i);
}
medium
A. 1 2 3 4 5
B. 1 2 4 5
C. 1 2 3 4
D. 2 3 4 5

Solution

  1. Step 1: Analyze loop iterations

    The loop runs i from 1 to 5. When i equals 3, the continue statement skips printing.
  2. Step 2: Determine printed values

    Values 1, 2, 4, and 5 are printed with spaces. The number 3 is skipped.
  3. Final Answer:

    1 2 4 5 -> Option B
  4. Quick Check:

    continue skips printing 3 [OK]
Hint: Skip printing when continue triggers, others print normally [OK]
Common Mistakes:
  • Including the skipped number in output
  • Confusing continue with break
  • Ignoring the loop condition
4. Identify the error in this code snippet using continue:
int i = 0;
while (i < 5) {
    if (i == 2)
        continue;
    printf("%d ", i);
    i++;
}
medium
A. Syntax error: continue cannot be used in while loops
B. The printf statement is unreachable
C. The loop will run infinitely because 'i' is not incremented when i == 2
D. The variable 'i' is not declared properly

Solution

  1. Step 1: Understand loop flow with continue

    When i equals 2, continue skips the rest of the loop body, so i++ is not executed.
  2. Step 2: Consequence of skipping i++

    Since i is not incremented at i == 2, the loop condition remains true forever, causing an infinite loop.
  3. Final Answer:

    The loop will run infinitely because 'i' is not incremented when i == 2 -> Option C
  4. Quick Check:

    continue skips i++ causing infinite loop [OK]
Hint: Always increment loop variable before continue to avoid infinite loops [OK]
Common Mistakes:
  • Thinking continue causes syntax error
  • Assuming printf is unreachable
  • Ignoring loop variable increment
5. How can you modify this code to print only odd numbers from 1 to 10 using continue?
for (int i = 1; i <= 10; i++) {
    printf("%d ", i);
}
hard
A. Add if (i == 2) continue; before printf
B. Add if (i % 2 != 0) continue; before printf
C. Replace printf with if (i % 2 != 0) printf("%d ", i);
D. Add if (i % 2 == 0) continue; before printf

Solution

  1. Step 1: Identify condition to skip even numbers

    Even numbers satisfy i % 2 == 0. Using continue here skips printing even numbers.
  2. Step 2: Place continue before printf

    Adding if (i % 2 == 0) continue; before printf skips printing even numbers, so only odd numbers print.
  3. Final Answer:

    Add if (i % 2 == 0) continue; before printf -> Option D
  4. Quick Check:

    continue skips even numbers, prints odd [OK]
Hint: Skip even numbers with continue to print only odds [OK]
Common Mistakes:
  • Skipping odd numbers instead of even
  • Using continue after printf
  • Incorrect condition for even numbers
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard